Skip to content

Commit 2317459

Browse files
committed
run of tests and documenation updates
1 parent 64f3f18 commit 2317459

File tree

3 files changed

+79
-47
lines changed

3 files changed

+79
-47
lines changed

coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

coverage.xml

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" ?>
2-
<coverage version="7.5.3" timestamp="1718284262278" lines-valid="660" lines-covered="186" line-rate="0.2818" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
3-
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.5.3 -->
2+
<coverage version="7.6.0" timestamp="1721509620435" lines-valid="686" lines-covered="187" line-rate="0.2726" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
3+
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.6.0 -->
44
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
55
<sources>
66
<source>/workspaces/devsetgo_lib</source>
@@ -311,7 +311,7 @@
311311
</class>
312312
</classes>
313313
</package>
314-
<package name="dsg_lib.common_functions" line-rate="0.1545" branch-rate="0" complexity="0">
314+
<package name="dsg_lib.common_functions" line-rate="0.1461" branch-rate="0" complexity="0">
315315
<classes>
316316
<class name="__init__.py" filename="dsg_lib/common_functions/__init__.py" complexity="0" line-rate="1" branch-rate="0">
317317
<methods/>
@@ -621,38 +621,64 @@
621621
<line number="231" hits="0"/>
622622
</lines>
623623
</class>
624-
<class name="logging_config.py" filename="dsg_lib/common_functions/logging_config.py" complexity="0" line-rate="0.1724" branch-rate="0">
624+
<class name="logging_config.py" filename="dsg_lib/common_functions/logging_config.py" complexity="0" line-rate="0.1091" branch-rate="0">
625625
<methods/>
626626
<lines>
627+
<line number="38" hits="1"/>
627628
<line number="39" hits="1"/>
628629
<line number="40" hits="1"/>
629630
<line number="41" hits="1"/>
630631
<line number="43" hits="1"/>
631632
<line number="46" hits="1"/>
632-
<line number="99" hits="0"/>
633-
<line number="103" hits="0"/>
634-
<line number="110" hits="0"/>
635-
<line number="116" hits="0"/>
636-
<line number="117" hits="0"/>
637-
<line number="118" hits="0"/>
638-
<line number="121" hits="0"/>
639-
<line number="122" hits="0"/>
633+
<line number="108" hits="0"/>
634+
<line number="112" hits="0"/>
635+
<line number="119" hits="0"/>
640636
<line number="125" hits="0"/>
641637
<line number="126" hits="0"/>
642-
<line number="129" hits="0"/>
643-
<line number="132" hits="0"/>
644-
<line number="133" hits="0"/>
645-
<line number="136" hits="0"/>
646-
<line number="139" hits="0"/>
647-
<line number="152" hits="0"/>
648-
<line number="179" hits="0"/>
649-
<line number="181" hits="0"/>
650-
<line number="182" hits="0"/>
651-
<line number="187" hits="0"/>
652-
<line number="198" hits="0"/>
653-
<line number="201" hits="0"/>
654-
<line number="202" hits="0"/>
655-
<line number="205" hits="0"/>
638+
<line number="127" hits="0"/>
639+
<line number="130" hits="0"/>
640+
<line number="131" hits="0"/>
641+
<line number="134" hits="0"/>
642+
<line number="135" hits="0"/>
643+
<line number="138" hits="0"/>
644+
<line number="141" hits="0"/>
645+
<line number="142" hits="0"/>
646+
<line number="145" hits="0"/>
647+
<line number="148" hits="0"/>
648+
<line number="161" hits="0"/>
649+
<line number="188" hits="0"/>
650+
<line number="190" hits="0"/>
651+
<line number="191" hits="0"/>
652+
<line number="196" hits="0"/>
653+
<line number="207" hits="0"/>
654+
<line number="209" hits="0"/>
655+
<line number="211" hits="0"/>
656+
<line number="212" hits="0"/>
657+
<line number="215" hits="0"/>
658+
<line number="218" hits="0"/>
659+
<line number="219" hits="0"/>
660+
<line number="220" hits="0"/>
661+
<line number="221" hits="0"/>
662+
<line number="222" hits="0"/>
663+
<line number="224" hits="0"/>
664+
<line number="225" hits="0"/>
665+
<line number="226" hits="0"/>
666+
<line number="227" hits="0"/>
667+
<line number="228" hits="0"/>
668+
<line number="229" hits="0"/>
669+
<line number="230" hits="0"/>
670+
<line number="231" hits="0"/>
671+
<line number="232" hits="0"/>
672+
<line number="234" hits="0"/>
673+
<line number="237" hits="0"/>
674+
<line number="238" hits="0"/>
675+
<line number="240" hits="0"/>
676+
<line number="243" hits="0"/>
677+
<line number="245" hits="0"/>
678+
<line number="246" hits="0"/>
679+
<line number="247" hits="0"/>
680+
<line number="249" hits="0"/>
681+
<line number="250" hits="0"/>
656682
</lines>
657683
</class>
658684
<class name="patterns.py" filename="dsg_lib/common_functions/patterns.py" complexity="0" line-rate="0.1765" branch-rate="0">

dsg_lib/common_functions/logging_config.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
This module provides a function to configure and set up a logger using the loguru package.
3+
This module provides a comprehensive logging setup using the loguru library, facilitating easy logging management for Python applications. The `config_log` function, central to this module, allows for extensive customization of logging behavior. It supports specifying the logging directory, log file name, logging level, and controls for log rotation, retention, and formatting among other features. Additionally, it offers advanced options like backtrace and diagnose for in-depth debugging, and the ability to append the application name to the log file for clearer identification.
44
5-
The `config_log` function takes several optional parameters to customize the logger's behavior,
6-
including the logging directory, log name, logging level, log rotation size, log retention period,
7-
and more. It also provides an option to append the application name to the log file name.
8-
9-
Example:
10-
```python
5+
Usage example:
116
from dsg_lib.common_functions.logging_config import config_log
127
138
config_log(
14-
logging_directory='logs', # Directory where logs will be stored
15-
log_name='log', # Name of the log file (extension will be added automatically set v0.12.2)
16-
logging_level='DEBUG', # Logging level
17-
log_rotation='100 MB', # Log rotation size
18-
log_retention='30 days', # Log retention period
19-
log_backtrace=True, # Enable backtrace
20-
log_format="<green>{time:YYYY-MM-DD HH:mm:ss.SSSSSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>", # Log format
21-
log_serializer=False, # Disable log serialization
22-
log_diagnose=True, # Enable diagnose
23-
app_name='my_app', # Application name
24-
append_app_name=True # Append application name to the log file name
9+
logging_directory='logs', # Directory for storing logs
10+
log_name='log', # Base name for log files
11+
logging_level='DEBUG', # Minimum logging level
12+
log_rotation='100 MB', # Size threshold for log rotation
13+
log_retention='30 days', # Duration to retain old log files
14+
log_backtrace=True, # Enable detailed backtraces in logs
15+
log_format="<green>{time:YYYY-MM-DD HH:mm:ss.SSSSSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>", # Custom log format
16+
log_serializer=False, # Toggle log serialization
17+
log_diagnose=True, # Enable diagnostic information in logs
18+
app_name='my_app', # Application name for log identification
19+
append_app_name=True # Append application name to log file names
20+
enqueue=True, # Enqueue log messages
21+
intercept_standard_logging=True, # Intercept standard Python logging
22+
file_sink=True # Use a file sink for logging
2523
)
2624
25+
# Example log messages
2726
logger.debug("This is a debug message")
2827
logger.info("This is an info message")
2928
logger.error("This is an error message")
3029
logger.warning("This is a warning message")
3130
logger.critical("This is a critical message")
32-
```
3331
3432
Author: Mike Ryan
35-
Date: 2024/05/16
33+
DateCreated: 2021/07/16
34+
DateUpdated: 2024/07/24
35+
3636
License: MIT
3737
"""
3838
import time
@@ -74,6 +74,9 @@ def config_log(
7474
- log_diagnose (bool): Whether to enable diagnose. Default is False.
7575
- app_name (str): The application name. Default is None.
7676
- append_app_name (bool): Whether to append the application name to the log file name. Default is False.
77+
- enqueue (bool): Whether to enqueue log messages. Default is True.
78+
- intercept_standard_logging (bool): Whether to intercept standard logging. Default is True.
79+
- file_sink (bool): Whether to use a file sink. Default is True.
7780
7881
Raises:
7982
- ValueError: If the provided logging level is not valid.
@@ -94,6 +97,9 @@ def config_log(
9497
log_diagnose=True,
9598
app_name='my_app',
9699
append_app_name=True
100+
enqueue=True,
101+
intercept_standard_logging=True,
102+
file_sink=True
97103
)
98104
```
99105
"""

0 commit comments

Comments
 (0)