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: README.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,13 +27,13 @@ The logging setup supports two main modes:
27
27
To initialize logging in your application, call the `setup()` function. You can specify whether to enable structured logging or use the default human-readable format.
28
28
29
29
```python
30
-
frommy_logging_moduleimportsetup
30
+
fromfloggingimportflogging
31
31
32
32
# Initialize logging
33
-
setup(level="INFO", structured=False) # Human-readable format
33
+
flogging.setup(level="INFO", structured=False) # Human-readable format
34
34
35
35
# Enable structured logging for production
36
-
setup(level="INFO", structured=True)
36
+
flogging.setup(level="INFO", structured=True)
37
37
```
38
38
39
39
#### Parameters for `setup()`
@@ -99,10 +99,10 @@ Example structured log output:
99
99
In structured logging mode, you can attach additional context to each log message by calling `set_context()`. This context is logged alongside the usual fields, allowing you to track custom metadata.
When logging large messages (e.g., serialized data or files), the `log_multipart()` function compresses and splits the message into smaller chunks to prevent issues with log size limits.
113
113
114
114
```python
115
-
from my_logging_module import log_multipart
115
+
import logging
116
+
from flogging import flogging
116
117
117
118
# Log a large message
118
-
log_multipart(logging.getLogger(), b"Large data to be logged")
119
+
flogging.log_multipart(logging.getLogger(), b"Large data to be logged")
119
120
```
120
121
121
122
This function will automatically split the message and log each chunk, ensuring the entire message is captured.
@@ -140,9 +141,9 @@ You can further customize the format by modifying the `AwesomeFormatter` class,
140
141
To enforce standards in your logging messages, such as preventing trailing dots in log messages, the module provides the `check_trailing_dot()` decorator. This can be applied to logging functions to raise an error if a message ends with a dot:
141
142
142
143
```python
143
-
frommy_logging_moduleimportcheck_trailing_dot
144
+
fromfloggingimportflogging
144
145
145
-
@check_trailing_dot
146
+
@flogging.check_trailing_dot
146
147
deflog_message(record):
147
148
# Your custom logging logic
148
149
pass
@@ -166,7 +167,7 @@ Here's a full example of how to use structured logging with command-line configu
166
167
```python
167
168
import argparse
168
169
import logging
169
-
from flogging import add_logging_args, set_context, setup
170
+
from flogging.floggingimport add_logging_args, set_context, setup
170
171
171
172
# Initialize logging
172
173
setup(level="INFO", structured=False) # Human-readable format
0 commit comments