Skip to content

Commit fb48771

Browse files
author
Bob Bui
committed
refactor: split main module to smaller modules
1 parent f8987c9 commit fb48771

File tree

9 files changed

+318
-298
lines changed

9 files changed

+318
-298
lines changed

Logging Workflow.png

93.9 KB
Loading

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@ you need to explicitly set JSONRequestLogFormatter as default formatter for any
205205
request_logger
206206

207207
```python
208+
import json_logging.formatters
209+
208210
request_logger = json_logging.get_request_logger()
209211
handler = logging.handlers.RotatingFileHandler(filename='log_req.log', maxBytes=5000000, backupCount=10)
210-
handler.setFormatter(json_logging.JSONRequestLogFormatter())
212+
handler.setFormatter(json_logging.formatters.JSONRequestLogFormatter())
211213
request_logger.addHandler(handler)
212214
```
213215

example/custom_log_format.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import sys
55

66
import json_logging
7+
import json_logging.formatters
78

89

910
def extra(**kw):
1011
'''Add the required nested props layer'''
1112
return {'extra': {'props': kw}}
1213

1314

14-
class CustomJSONLog(json_logging.JSONLogFormatter):
15+
class CustomJSONLog(json_logging.formatters.JSONLogFormatter):
1516
"""
1617
Customized logger
1718
"""

example/custom_log_format_request.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
import flask
66

77
import json_logging
8+
import json_logging.dto
9+
import json_logging.formatters
810

911

10-
class CustomRequestJSONLog(json_logging.JSONRequestLogFormatter):
12+
class CustomRequestJSONLog(json_logging.formatters.JSONRequestLogFormatter):
1113
"""
1214
Customized logger
1315
"""
@@ -24,7 +26,7 @@ def _format_log_object(self, record, request_util):
2426
return json_log_object
2527

2628

27-
class CustomDefaultRequestResponseDTO(json_logging.DefaultRequestResponseDTO):
29+
class CustomDefaultRequestResponseDTO(json_logging.dto.DefaultRequestResponseDTO):
2830
"""
2931
custom implementation
3032
"""

0 commit comments

Comments
 (0)