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
+81-26Lines changed: 81 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,22 @@
1
1
# -*- coding: utf-8 -*-
2
2
"""
3
-
This module provides a functionto 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.
4
4
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.
5
+
Usage example:
8
6
9
-
Example:
10
7
```python
11
8
from dsg_lib.common_functions.logging_config import config_log
12
9
13
10
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)
# Set the root logger's level to the lowest level possible
205
214
logging.getLogger().setLevel(logging.NOTSET)
215
+
216
+
217
+
classResilientFileSink:
218
+
"""
219
+
A file sink designed for resilience, capable of retrying write operations.
220
+
221
+
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.
222
+
223
+
Attributes:
224
+
path (str): The path to the file where messages will be written.
225
+
max_retries (int): The maximum number of retry attempts for a failed write operation.
226
+
retry_delay (float): The delay between retry attempts, in seconds.
227
+
228
+
Methods:
229
+
write(message): Attempts to write a message to the file, retrying on failure up to `max_retries` times.
0 commit comments