You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dsg_lib/common_functions/logging_config.py
+19-11Lines changed: 19 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
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.
4
4
5
5
Usage example:
6
+
7
+
```python
6
8
from dsg_lib.common_functions.logging_config import config_log
7
9
8
10
config_log(
@@ -11,15 +13,7 @@
11
13
logging_level='DEBUG', # Minimum logging level
12
14
log_rotation='100 MB', # Size threshold for log rotation
13
15
log_retention='30 days', # Duration to retain old log files
14
-
log_backtrace=True, # Enable detailed backtraces in logs
A file sink designed for resilience, capable of retrying write operations.
216
+
217
+
This class implements a resilient file writing mechanism that attempts to write messages to a file, retrying the operation a specified number of times if it fails. This is particularly useful in scenarios where write operations might intermittently fail due to temporary issues such as file system locks or networked file system delays.
218
+
219
+
Attributes:
220
+
path (str): The path to the file where messages will be written.
221
+
max_retries (int): The maximum number of retry attempts for a failed write operation.
222
+
retry_delay (float): The delay between retry attempts, in seconds.
223
+
224
+
Methods:
225
+
write(message): Attempts to write a message to the file, retrying on failure up to `max_retries` times.
0 commit comments