@@ -155,12 +155,18 @@ logger.info("Logging info.")
155155
156156``` yml
157157logger :
158- app_name : " my-app"
159- level : " TRACE"
160- file :
161- log_handlers :
158+ app_name : my-app
159+ default :
160+ level :
161+ base : TRACE
162+ handlers :
163+ default.all.file_handler :
162164 enabled : true
163- json_handlers :
165+ default.err.file_handler :
166+ enabled : true
167+ default.all.json_handler :
168+ enabled : true
169+ default.err.json_handler :
164170 enabled : true
165171` ` `
166172
@@ -211,28 +217,28 @@ python ./main.py
211217**Output**:
212218
213219` ` ` txt
214- [2023-09 -01 00:00:00.000 +09:00 | TRACE | beans_logging._base:478 ]: Intercepted modules: ['concurrent', 'concurrent.futures', 'asyncio']; Muted modules: [];
215- [2023-09 -01 00:00:00.000 +09:00 | TRACE | __main__:7 ]: Tracing...
216- [2023-09 -01 00:00:00.000 +09:00 | DEBUG | __main__:8 ]: Debugging...
217- [2023-09 -01 00:00:00.000 +09:00 | INFO | __main__:9 ]: Logging info.
218- [2023-09 -01 00:00:00.000 +09:00 | OK | __main__:10 ]: Success.
219- [2023-09 -01 00:00:00.000 +09:00 | WARN | __main__:11 ]: Warning something.
220- [2023-09 -01 00:00:00.000 +09:00 | ERROR | __main__:12 ]: Error occured.
221- [2023-09 -01 00:00:00.000 +09:00 | CRIT | __main__:13 ]: CRITICAL ERROR.
222- [2023-09 -01 00:00:00.000 +09:00 | ERROR | __main__:25 ]: division by zero
223- [2023-09 -01 00:00:00.000 +09:00 | ERROR | __main__:32 ]: Show me, what value is wrong:
220+ [2025-11 -01 00:00:00.735 +09:00 | TRACE | beans_logging._intercept:96 ]: Intercepted modules: ['potato_util._base', 'potato_util.io', ' concurrent', 'concurrent.futures', 'asyncio', 'potato_util.io._sync', 'potato_util ']; Muted modules: [];
221+ [2025-11 -01 00:00:00.736 +09:00 | TRACE | __main__:6 ]: Tracing...
222+ [2025-11 -01 00:00:00.736 +09:00 | DEBUG | __main__:7 ]: Debugging...
223+ [2025-11 -01 00:00:00.736 +09:00 | INFO | __main__:8 ]: Logging info.
224+ [2025-11 -01 00:00:00.736 +09:00 | OK | __main__:9 ]: Success.
225+ [2025-11 -01 00:00:00.736 +09:00 | WARN | __main__:10 ]: Warning something.
226+ [2025-11 -01 00:00:00.736 +09:00 | ERROR | __main__:11 ]: Error occured.
227+ [2025-11 -01 00:00:00.736 +09:00 | CRIT | __main__:12 ]: CRITICAL ERROR.
228+ [2025-11 -01 00:00:00.736 +09:00 | ERROR | __main__:24 ]: division by zero
229+ [2025-11 -01 00:00:00.737 +09:00 | ERROR | __main__:31 ]: Show me, what value is wrong:
224230Traceback (most recent call last):
225231
226- > File "/home/user/workspaces/projects/beans_logging/ examples/simple/./main.py", line 30 , in <module>
232+ > File "/home/user/workspaces/projects/my/module-python-logging/ examples/simple/./main.py", line 29 , in <module>
227233 nested(0)
228- └ <function nested at 0x10802a4c0 >
234+ └ <function nested at 0x102f37910 >
229235
230- File "/home/user/workspaces/projects/beans_logging/ examples/simple/./main.py", line 23 , in nested
236+ File "/home/user/workspaces/projects/my/module-python-logging/ examples/simple/./main.py", line 22 , in nested
231237 divide(5, c)
232238 │ └ 0
233- └ <function divide at 0x1052f31f0 >
239+ └ <function divide at 0x102f377f0 >
234240
235- File "/home/user/workspaces/projects/beans_logging/ examples/simple/./main.py", line 17 , in divide
241+ File "/home/user/workspaces/projects/my/module-python-logging/ examples/simple/./main.py", line 16 , in divide
236242 _result = a / b
237243 │ └ 0
238244 └ 5
@@ -250,37 +256,54 @@ ZeroDivisionError: division by zero
250256
251257` ` ` yaml
252258logger:
253- # app_name: "app"
254- level: "INFO"
255- use_diagnose: false
256- stream:
257- use_color: true
258- use_icon: false
259- format_str: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{level_short:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
260- std_handler:
261- enabled: true
262- file:
263- logs_dir: "./logs"
264- rotate_size: 10000000 # 10MB
265- rotate_time: "00:00:00"
266- backup_count: 90
267- log_handlers:
268- enabled: false
269- format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {level_short:<5} | {name}:{line}]: {message}"
270- log_path: "{app_name}.std.all.log"
271- err_path: "{app_name}.std.err.log"
272- json_handlers:
273- enabled: false
274- use_custom: false
275- log_path: "{app_name}.json.all.log"
276- err_path: "{app_name}.json.err.log"
259+ # app_name: app
260+ default:
261+ level:
262+ base: INFO
263+ err: WARNING
264+ std:
265+ format_str: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
266+ colorize: true
267+ format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line}]: {message}"
268+ file:
269+ logs_dir: "./logs"
270+ rotate_size: 10000000
271+ rotate_time: "00:00:00"
272+ retention: 90
273+ encoding: utf8
274+ plain:
275+ log_path: "{app_name}.all.log"
276+ err_path: "{app_name}.err.log"
277+ json:
278+ log_path: "json/{app_name}.json.all.log"
279+ err_path: "json/{app_name}.json.err.log"
280+ custom_serialize: false
277281 intercept:
278- auto_load:
279- enabled: true
280- only_base: false
281- ignore_modules: []
282+ enabled: true
283+ only_base: false
284+ ignore_modules: []
282285 include_modules: []
283286 mute_modules: []
287+ handlers:
288+ default.all.std_handler:
289+ type: STD
290+ enabled: true
291+ default.all.file_handler:
292+ type: FILE
293+ enabled: false
294+ default.err.file_handler:
295+ type: FILE
296+ error: true
297+ enabled: false
298+ default.all.json_handler:
299+ type: FILE
300+ serialize: true
301+ enabled: false
302+ default.err.json_handler:
303+ type: FILE
304+ serialize: true
305+ error: true
306+ enabled: false
284307 extra:
285308` ` `
286309
@@ -292,10 +315,6 @@ logger:
292315# ENV=LOCAL
293316# DEBUG=false
294317# TZ=UTC
295-
296- # BEANS_LOGGING_DISABLE_DEFAULT=false
297- # BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
298- # BEANS_LOGGING_LOGS_DIR="./logs"
299318` ` `
300319
301320---
0 commit comments