beans-logging-fastapi 6.0.4__tar.gz → 7.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {beans_logging_fastapi-6.0.4/src/beans_logging_fastapi.egg-info → beans_logging_fastapi-7.0.0}/PKG-INFO +58 -46
  2. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/README.md +56 -44
  3. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/pyproject.toml +1 -1
  4. beans_logging_fastapi-7.0.0/requirements.txt +2 -0
  5. beans_logging_fastapi-7.0.0/src/beans_logging_fastapi/__version__.py +1 -0
  6. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/config.py +29 -11
  7. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/middlewares.py +11 -5
  8. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0/src/beans_logging_fastapi.egg-info}/PKG-INFO +58 -46
  9. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi.egg-info/requires.txt +1 -1
  10. beans_logging_fastapi-6.0.4/requirements.txt +0 -2
  11. beans_logging_fastapi-6.0.4/src/beans_logging_fastapi/__version__.py +0 -1
  12. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/.python-version +0 -0
  13. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/LICENSE.txt +0 -0
  14. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/requirements/requirements.build.txt +0 -0
  15. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/requirements/requirements.dev.txt +0 -0
  16. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/requirements/requirements.docs.txt +0 -0
  17. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/requirements/requirements.test.txt +0 -0
  18. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/setup.cfg +0 -0
  19. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/setup.py +0 -0
  20. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/__init__.py +0 -0
  21. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/_async.py +0 -0
  22. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/_core.py +0 -0
  23. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/constants.py +0 -0
  24. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/filters.py +0 -0
  25. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/formats.py +0 -0
  26. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/http_error.py +0 -0
  27. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi/mode.py +0 -0
  28. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi.egg-info/SOURCES.txt +0 -0
  29. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi.egg-info/dependency_links.txt +0 -0
  30. {beans_logging_fastapi-6.0.4 → beans_logging_fastapi-7.0.0}/src/beans_logging_fastapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beans_logging_fastapi
3
- Version: 6.0.4
3
+ Version: 7.0.0
4
4
  Summary: This is a HTTP access log module for FastAPI based on 'beans-logging' package.
5
5
  Author-email: Batkhuu Byambajav <batkhuu10@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/bybatkhuu/module-fastapi-logging
@@ -22,7 +22,7 @@ Requires-Python: <4.0,>=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE.txt
24
24
  Requires-Dist: fastapi<1.0.0,>=0.99.1
25
- Requires-Dist: beans-logging<12.0.0,>=11.0.2
25
+ Requires-Dist: beans-logging<13.0.0,>=12.0.0
26
26
  Provides-Extra: test
27
27
  Requires-Dist: pytest<10.0.0,>=8.0.2; extra == "test"
28
28
  Requires-Dist: pytest-cov<8.0.0,>=5.0.0; extra == "test"
@@ -170,29 +170,36 @@ logger:
170
170
  app_name: "fastapi-app"
171
171
  level:
172
172
  base: TRACE
173
+ default_format: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
173
174
  http:
174
175
  std:
175
- format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
176
- err_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
177
- debug_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
176
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
177
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
178
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
178
179
  file:
179
180
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
180
181
  tz: "localtime"
181
- has_proxy_headers: true
182
- has_cf_headers: true
182
+ has_proxy_headers: false
183
+ has_cf_headers: false
183
184
  intercept:
184
185
  mute_modules: ["uvicorn.access"]
185
186
  handlers:
186
- http.access.file_handler:
187
+ std_handler:
188
+ enabled: true
189
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
190
+ http_access_std_handler:
191
+ enabled: true
192
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
193
+ http_access_file_handler:
187
194
  enabled: true
188
195
  sink: "http/{app_name}.http-access.log"
189
- http.err.file_handler:
196
+ http_err_file_handler:
190
197
  enabled: true
191
198
  sink: "http/{app_name}.http-err.log"
192
- http.access.json_handler:
199
+ http_access_json_handler:
193
200
  enabled: true
194
201
  sink: "http.json/{app_name}.http-access.json.log"
195
- http.err.json_handler:
202
+ http_err_json_handler:
196
203
  enabled: true
197
204
  sink: "http.json/{app_name}.http-err.json.log"
198
205
  ```
@@ -410,24 +417,25 @@ uvicorn main:app --host=0.0.0.0 --port=8000
410
417
  **Output**:
411
418
 
412
419
  ```txt
413
- [2026-01-01 12:00:00.002 +09:00 | TRACE | beans_logging.intercepters:96]: Intercepted modules: ['uvicorn', 'potato_util', 'fastapi', 'uvicorn.error', 'watchfiles.watcher', 'concurrent.futures', 'watchfiles', 'asyncio', 'concurrent', 'potato_util._base', 'dotenv', 'dotenv.main', 'watchfiles.main', 'potato_util.io', 'potato_util.io._sync']; Muted modules: ['uvicorn.access'];
414
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.server:84]: Started server process [88375]
415
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.lifespan.on:48]: Waiting for application startup.
416
- [2026-01-01 12:00:00.004 +09:00 | TRACE | lifespan:19]: TRACE diagnosis is ON!
417
- [2026-01-01 12:00:00.004 +09:00 | DEBUG | lifespan:20]: DEBUG mode is ON!
418
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:21]: Preparing to startup...
419
- [2026-01-01 12:00:00.004 +09:00 | OK | lifespan:24]: Finished preparation to startup.
420
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:25]: Version: 0.0.0
421
- [2026-01-01 12:00:00.005 +09:00 | INFO | uvicorn.lifespan.on:62]: Application startup complete.
422
- [2026-01-01 12:00:00.006 +09:00 | INFO | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
423
- [2026-01-01 12:00:01.775 +09:00 | DEBUG ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1"
424
- [2026-01-01 12:00:01.783 +09:00 | OK ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1" 200 17B 5.7ms
425
- ^C[2026-01-01 12:00:02.368 +09:00 | INFO | uvicorn.server:264]: Shutting down
426
- [2026-01-01 12:00:02.470 +09:00 | INFO | uvicorn.lifespan.on:67]: Waiting for application shutdown.
427
- [2026-01-01 12:00:02.472 +09:00 | INFO | lifespan:29]: Preparing to shutdown...
428
- [2026-01-01 12:00:02.472 +09:00 | OK | lifespan:31]: Finished preparation to shutdown.
429
- [2026-01-01 12:00:02.473 +09:00 | INFO | uvicorn.lifespan.on:76]: Application shutdown complete.
430
- [2026-01-01 12:00:02.474 +09:00 | INFO | uvicorn.server:94]: Finished server process [88375]
420
+ [2026-06-05 00:55:29.335 +09:00 | TRACE | - | beans_logging.intercepters:96]: Intercepted modules: ['potato_util', 'dotenv.main', 'concurrent', 'potato_util.io', 'asyncio', 'fastapi', 'concurrent.futures', 'dotenv', 'uvicorn', 'watchfiles.watcher', 'potato_util.io._sync', 'watchfiles.main', 'potato_util._base', 'uvicorn.error', 'watchfiles']; Muted modules: ['uvicorn.access'];
421
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.server:84]: Started server process [95017]
422
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.lifespan.on:48]: Waiting for application startup.
423
+ [2026-06-05 00:55:29.337 +09:00 | TRACE | - | lifespan:19]: TRACE diagnosis is ON!
424
+ [2026-06-05 00:55:29.337 +09:00 | DEBUG | - | lifespan:20]: DEBUG mode is ON!
425
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:21]: Preparing to startup...
426
+ [2026-06-05 00:55:29.337 +09:00 | OK | - | lifespan:24]: Finished preparation to startup.
427
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:25]: Version: 0.0.0
428
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | uvicorn.lifespan.on:62]: Application startup complete.
429
+ [2026-06-05 00:55:29.339 +09:00 | INFO | - | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
430
+ [2026-06-05 00:55:33.367 +09:00 | DEBUG | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1"
431
+ [2026-06-05 00:55:33.370 +09:00 | INFO | 58c916d045844314bb6c10b390ad5593 | router:11]: Root endpoint accessed.
432
+ [2026-06-05 00:55:33.371 +09:00 | OK | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1" 200 17B 3.0ms
433
+ ^C[2026-06-05 00:55:35.702 +09:00 | INFO | - | uvicorn.server:264]: Shutting down
434
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:67]: Waiting for application shutdown.
435
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | lifespan:29]: Preparing to shutdown...
436
+ [2026-06-05 00:55:35.805 +09:00 | OK | - | lifespan:31]: Finished preparation to shutdown.
437
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:76]: Application shutdown complete.
438
+ [2026-06-05 00:55:35.806 +09:00 | INFO | - | uvicorn.server:94]: Finished server process [95017]
431
439
  ```
432
440
 
433
441
  👍
@@ -444,19 +452,19 @@ logger:
444
452
  level:
445
453
  base: INFO
446
454
  err: WARNING
447
- format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line}]: {message}"
455
+ format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
448
456
  file:
449
457
  logs_dir: "./logs"
450
458
  rotate_size: 10000000
451
459
  rotate_time: "00:00:00"
452
460
  retention: 90
453
461
  encoding: utf8
454
- use_custom_serialize: false
462
+ custom_serialize: false
455
463
  http:
456
464
  std:
457
- msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
458
- err_msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
459
- debug_msg_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
465
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
466
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
467
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
460
468
  file:
461
469
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
462
470
  tz: localtime
@@ -468,53 +476,57 @@ logger:
468
476
  ignore_modules: []
469
477
  include_modules: []
470
478
  mute_modules: [uvicorn.access]
479
+ global_extra:
480
+ trace_id: "-"
481
+ request_id: "-"
482
+ user_id: "-"
471
483
  handlers:
472
484
  std_handler:
473
485
  enabled: true
474
- h_type: STD
475
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
486
+ type_: STD
487
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
476
488
  colorize: true
477
489
  file_handler:
478
490
  enabled: true
479
- h_type: FILE
491
+ type_: FILE
480
492
  sink: "{app_name}.all.log"
481
493
  err_file_handler:
482
494
  enabled: true
483
- h_type: FILE
495
+ type_: FILE
484
496
  sink: "{app_name}.err.log"
485
497
  error: true
486
498
  json_handler:
487
499
  enabled: true
488
- h_type: FILE
500
+ type_: FILE
489
501
  sink: "json/{app_name}.all.json.log"
490
502
  serialize: true
491
503
  err_json_handler:
492
504
  enabled: true
493
- h_type: FILE
505
+ type_: FILE
494
506
  sink: "json/{app_name}.err.json.log"
495
507
  serialize: true
496
508
  error: true
497
509
  http_access_std_handler:
498
510
  enabled: true
499
- h_type: STD
500
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> ]: <level>{message}</level>"
511
+ type_: STD
512
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
501
513
  colorize: true
502
514
  http_access_file_handler:
503
515
  enabled: true
504
- h_type: FILE
516
+ type_: FILE
505
517
  sink: "http/{app_name}.http-access.log"
506
518
  http_err_file_handler:
507
519
  enabled: true
508
- h_type: FILE
520
+ type_: FILE
509
521
  sink: "http/{app_name}.http-err.log"
510
522
  error: true
511
523
  http_access_json_handler:
512
524
  enabled: true
513
- h_type: FILE
525
+ type_: FILE
514
526
  sink: "http.json/{app_name}.http-access.json.log"
515
527
  http_err_json_handler:
516
528
  enabled: true
517
- h_type: FILE
529
+ type_: FILE
518
530
  sink: "http.json/{app_name}.http-err.json.log"
519
531
  error: true
520
532
  extra:
@@ -108,29 +108,36 @@ logger:
108
108
  app_name: "fastapi-app"
109
109
  level:
110
110
  base: TRACE
111
+ default_format: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
111
112
  http:
112
113
  std:
113
- format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
114
- err_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
115
- debug_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
114
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
115
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
116
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
116
117
  file:
117
118
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
118
119
  tz: "localtime"
119
- has_proxy_headers: true
120
- has_cf_headers: true
120
+ has_proxy_headers: false
121
+ has_cf_headers: false
121
122
  intercept:
122
123
  mute_modules: ["uvicorn.access"]
123
124
  handlers:
124
- http.access.file_handler:
125
+ std_handler:
126
+ enabled: true
127
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
128
+ http_access_std_handler:
129
+ enabled: true
130
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
131
+ http_access_file_handler:
125
132
  enabled: true
126
133
  sink: "http/{app_name}.http-access.log"
127
- http.err.file_handler:
134
+ http_err_file_handler:
128
135
  enabled: true
129
136
  sink: "http/{app_name}.http-err.log"
130
- http.access.json_handler:
137
+ http_access_json_handler:
131
138
  enabled: true
132
139
  sink: "http.json/{app_name}.http-access.json.log"
133
- http.err.json_handler:
140
+ http_err_json_handler:
134
141
  enabled: true
135
142
  sink: "http.json/{app_name}.http-err.json.log"
136
143
  ```
@@ -348,24 +355,25 @@ uvicorn main:app --host=0.0.0.0 --port=8000
348
355
  **Output**:
349
356
 
350
357
  ```txt
351
- [2026-01-01 12:00:00.002 +09:00 | TRACE | beans_logging.intercepters:96]: Intercepted modules: ['uvicorn', 'potato_util', 'fastapi', 'uvicorn.error', 'watchfiles.watcher', 'concurrent.futures', 'watchfiles', 'asyncio', 'concurrent', 'potato_util._base', 'dotenv', 'dotenv.main', 'watchfiles.main', 'potato_util.io', 'potato_util.io._sync']; Muted modules: ['uvicorn.access'];
352
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.server:84]: Started server process [88375]
353
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.lifespan.on:48]: Waiting for application startup.
354
- [2026-01-01 12:00:00.004 +09:00 | TRACE | lifespan:19]: TRACE diagnosis is ON!
355
- [2026-01-01 12:00:00.004 +09:00 | DEBUG | lifespan:20]: DEBUG mode is ON!
356
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:21]: Preparing to startup...
357
- [2026-01-01 12:00:00.004 +09:00 | OK | lifespan:24]: Finished preparation to startup.
358
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:25]: Version: 0.0.0
359
- [2026-01-01 12:00:00.005 +09:00 | INFO | uvicorn.lifespan.on:62]: Application startup complete.
360
- [2026-01-01 12:00:00.006 +09:00 | INFO | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
361
- [2026-01-01 12:00:01.775 +09:00 | DEBUG ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1"
362
- [2026-01-01 12:00:01.783 +09:00 | OK ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1" 200 17B 5.7ms
363
- ^C[2026-01-01 12:00:02.368 +09:00 | INFO | uvicorn.server:264]: Shutting down
364
- [2026-01-01 12:00:02.470 +09:00 | INFO | uvicorn.lifespan.on:67]: Waiting for application shutdown.
365
- [2026-01-01 12:00:02.472 +09:00 | INFO | lifespan:29]: Preparing to shutdown...
366
- [2026-01-01 12:00:02.472 +09:00 | OK | lifespan:31]: Finished preparation to shutdown.
367
- [2026-01-01 12:00:02.473 +09:00 | INFO | uvicorn.lifespan.on:76]: Application shutdown complete.
368
- [2026-01-01 12:00:02.474 +09:00 | INFO | uvicorn.server:94]: Finished server process [88375]
358
+ [2026-06-05 00:55:29.335 +09:00 | TRACE | - | beans_logging.intercepters:96]: Intercepted modules: ['potato_util', 'dotenv.main', 'concurrent', 'potato_util.io', 'asyncio', 'fastapi', 'concurrent.futures', 'dotenv', 'uvicorn', 'watchfiles.watcher', 'potato_util.io._sync', 'watchfiles.main', 'potato_util._base', 'uvicorn.error', 'watchfiles']; Muted modules: ['uvicorn.access'];
359
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.server:84]: Started server process [95017]
360
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.lifespan.on:48]: Waiting for application startup.
361
+ [2026-06-05 00:55:29.337 +09:00 | TRACE | - | lifespan:19]: TRACE diagnosis is ON!
362
+ [2026-06-05 00:55:29.337 +09:00 | DEBUG | - | lifespan:20]: DEBUG mode is ON!
363
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:21]: Preparing to startup...
364
+ [2026-06-05 00:55:29.337 +09:00 | OK | - | lifespan:24]: Finished preparation to startup.
365
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:25]: Version: 0.0.0
366
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | uvicorn.lifespan.on:62]: Application startup complete.
367
+ [2026-06-05 00:55:29.339 +09:00 | INFO | - | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
368
+ [2026-06-05 00:55:33.367 +09:00 | DEBUG | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1"
369
+ [2026-06-05 00:55:33.370 +09:00 | INFO | 58c916d045844314bb6c10b390ad5593 | router:11]: Root endpoint accessed.
370
+ [2026-06-05 00:55:33.371 +09:00 | OK | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1" 200 17B 3.0ms
371
+ ^C[2026-06-05 00:55:35.702 +09:00 | INFO | - | uvicorn.server:264]: Shutting down
372
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:67]: Waiting for application shutdown.
373
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | lifespan:29]: Preparing to shutdown...
374
+ [2026-06-05 00:55:35.805 +09:00 | OK | - | lifespan:31]: Finished preparation to shutdown.
375
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:76]: Application shutdown complete.
376
+ [2026-06-05 00:55:35.806 +09:00 | INFO | - | uvicorn.server:94]: Finished server process [95017]
369
377
  ```
370
378
 
371
379
  👍
@@ -382,19 +390,19 @@ logger:
382
390
  level:
383
391
  base: INFO
384
392
  err: WARNING
385
- format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line}]: {message}"
393
+ format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
386
394
  file:
387
395
  logs_dir: "./logs"
388
396
  rotate_size: 10000000
389
397
  rotate_time: "00:00:00"
390
398
  retention: 90
391
399
  encoding: utf8
392
- use_custom_serialize: false
400
+ custom_serialize: false
393
401
  http:
394
402
  std:
395
- msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
396
- err_msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
397
- debug_msg_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
403
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
404
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
405
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
398
406
  file:
399
407
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
400
408
  tz: localtime
@@ -406,53 +414,57 @@ logger:
406
414
  ignore_modules: []
407
415
  include_modules: []
408
416
  mute_modules: [uvicorn.access]
417
+ global_extra:
418
+ trace_id: "-"
419
+ request_id: "-"
420
+ user_id: "-"
409
421
  handlers:
410
422
  std_handler:
411
423
  enabled: true
412
- h_type: STD
413
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
424
+ type_: STD
425
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
414
426
  colorize: true
415
427
  file_handler:
416
428
  enabled: true
417
- h_type: FILE
429
+ type_: FILE
418
430
  sink: "{app_name}.all.log"
419
431
  err_file_handler:
420
432
  enabled: true
421
- h_type: FILE
433
+ type_: FILE
422
434
  sink: "{app_name}.err.log"
423
435
  error: true
424
436
  json_handler:
425
437
  enabled: true
426
- h_type: FILE
438
+ type_: FILE
427
439
  sink: "json/{app_name}.all.json.log"
428
440
  serialize: true
429
441
  err_json_handler:
430
442
  enabled: true
431
- h_type: FILE
443
+ type_: FILE
432
444
  sink: "json/{app_name}.err.json.log"
433
445
  serialize: true
434
446
  error: true
435
447
  http_access_std_handler:
436
448
  enabled: true
437
- h_type: STD
438
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> ]: <level>{message}</level>"
449
+ type_: STD
450
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
439
451
  colorize: true
440
452
  http_access_file_handler:
441
453
  enabled: true
442
- h_type: FILE
454
+ type_: FILE
443
455
  sink: "http/{app_name}.http-access.log"
444
456
  http_err_file_handler:
445
457
  enabled: true
446
- h_type: FILE
458
+ type_: FILE
447
459
  sink: "http/{app_name}.http-err.log"
448
460
  error: true
449
461
  http_access_json_handler:
450
462
  enabled: true
451
- h_type: FILE
463
+ type_: FILE
452
464
  sink: "http.json/{app_name}.http-access.json.log"
453
465
  http_err_json_handler:
454
466
  enabled: true
455
- h_type: FILE
467
+ type_: FILE
456
468
  sink: "http.json/{app_name}.http-err.json.log"
457
469
  error: true
458
470
  extra:
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=70.3.0,<83.0.0", "setuptools-scm>=8.0.4,<10.0.0"]
2
+ requires = ["setuptools>=70.3.0,<83.0.0", "setuptools-scm>=8.0.4,<11.0.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -0,0 +1,2 @@
1
+ fastapi>=0.99.1,<1.0.0
2
+ beans-logging>=12.0.0,<13.0.0
@@ -0,0 +1 @@
1
+ __version__ = "7.0.0"
@@ -3,7 +3,11 @@ from typing import Any
3
3
  import potato_util as utils
4
4
  from pydantic import Field, field_validator
5
5
 
6
- from beans_logging.constants import LogHandlerTypeEnum, DEFAULT_HANDLER_NAMES
6
+ from beans_logging.constants import (
7
+ LogHandlerTypeEnum,
8
+ DEFAULT_HANDLER_NAMES,
9
+ DEFAULT_STD_HANDLER_NAME,
10
+ )
7
11
  from beans_logging.schemas import LogHandlerPM
8
12
  from beans_logging.config import (
9
13
  get_default_handlers as get_base_handlers,
@@ -33,30 +37,36 @@ def get_default_handlers() -> dict[str, LogHandlerPM]:
33
37
  if _name in DEFAULT_HANDLER_NAMES:
34
38
  _handler.enabled = True
35
39
 
40
+ if _name == DEFAULT_STD_HANDLER_NAME:
41
+ _handler.format_ = (
42
+ "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | "
43
+ "<w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
44
+ )
45
+
36
46
  _http_handlers: dict[str, LogHandlerPM] = {
37
47
  HTTP_ACCESS_STD_HANDLER_NAME: LogHandlerPM(
38
- h_type=LogHandlerTypeEnum.STD,
48
+ type_=LogHandlerTypeEnum.STD,
39
49
  format_=(
40
- "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> ]:"
41
- " <level>{message}</level>"
50
+ "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | "
51
+ "<w>{extra[request_id]}</w>]: <level>{message}</level>"
42
52
  ),
43
53
  colorize=True,
44
54
  ),
45
55
  HTTP_ACCESS_FILE_HANDLER_NAME: LogHandlerPM(
46
- h_type=LogHandlerTypeEnum.FILE,
56
+ type_=LogHandlerTypeEnum.FILE,
47
57
  sink="http/{app_name}.http-access.log",
48
58
  ),
49
59
  HTTP_ERR_FILE_HANDLER_NAME: LogHandlerPM(
50
- h_type=LogHandlerTypeEnum.FILE,
60
+ type_=LogHandlerTypeEnum.FILE,
51
61
  sink="http/{app_name}.http-err.log",
52
62
  error=True,
53
63
  ),
54
64
  HTTP_ACCESS_JSON_HANDLER_NAME: LogHandlerPM(
55
- h_type=LogHandlerTypeEnum.FILE,
65
+ type_=LogHandlerTypeEnum.FILE,
56
66
  sink="http.json/{app_name}.http-access.json.log",
57
67
  ),
58
68
  HTTP_ERR_JSON_HANDLER_NAME: LogHandlerPM(
59
- h_type=LogHandlerTypeEnum.FILE,
69
+ type_=LogHandlerTypeEnum.FILE,
60
70
  sink="http.json/{app_name}.http-err.json.log",
61
71
  error=True,
62
72
  ),
@@ -74,7 +84,7 @@ def get_default_intercept() -> InterceptConfigPM:
74
84
  class StdConfigPM(ExtraBaseModel):
75
85
  msg_format_str: str = Field(
76
86
  default=(
77
- '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
87
+ '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
78
88
  " {status_code} {content_length}B {response_time}ms"
79
89
  ),
80
90
  min_length=8,
@@ -82,14 +92,14 @@ class StdConfigPM(ExtraBaseModel):
82
92
  )
83
93
  err_msg_format_str: str = Field(
84
94
  default=(
85
- '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
95
+ '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
86
96
  " <n>{status_code}</n>"
87
97
  ),
88
98
  min_length=8,
89
99
  max_length=512,
90
100
  )
91
101
  debug_msg_format_str: str = Field(
92
- default='<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"',
102
+ default='{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"',
93
103
  min_length=8,
94
104
  max_length=512,
95
105
  )
@@ -115,6 +125,14 @@ class HttpConfigPM(ExtraBaseModel):
115
125
 
116
126
 
117
127
  class LoggerConfigPM(BaseLoggerConfigPM):
128
+ default_format: str = Field(
129
+ default=(
130
+ "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: "
131
+ "{message}"
132
+ ),
133
+ min_length=8,
134
+ max_length=512,
135
+ )
118
136
  http: HttpConfigPM = Field(default_factory=HttpConfigPM)
119
137
  intercept: InterceptConfigPM = Field(default_factory=get_default_intercept)
120
138
  handlers: dict[str, LogHandlerPM] = Field(default_factory=get_default_handlers)
@@ -162,7 +162,10 @@ class RequestHTTPInfoMiddleware(BaseHTTPMiddleware):
162
162
  if hasattr(request.state, "user_id"):
163
163
  _http_info["user_id"] = str(request.state.user_id)
164
164
 
165
+ _logger = logger.bind(request_id=_http_info["request_id"])
166
+
165
167
  # Set http info to request state:
168
+ request.state.logger = _logger
166
169
  request.state.http_info = _http_info
167
170
  response: Response = await call_next(request)
168
171
  return response
@@ -250,11 +253,10 @@ class HttpAccessLogMiddleware(BaseHTTPMiddleware):
250
253
  """
251
254
 
252
255
  _DEBUG_MSG_FORMAT_STR = (
253
- '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u>'
254
- ' HTTP/{http_version}"'
256
+ '{client_host} {user_id} "<u>{method} {url_path}</u>' ' HTTP/{http_version}"'
255
257
  )
256
258
  _MSG_FORMAT_STR = (
257
- '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
259
+ '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
258
260
  " {status_code} {content_length}B {response_time}ms"
259
261
  )
260
262
 
@@ -284,7 +286,9 @@ class HttpAccessLogMiddleware(BaseHTTPMiddleware):
284
286
  _debug_msg = self.debug_msg_format_str.format(**_http_info)
285
287
 
286
288
  _logger.bind(
287
- http_info=_http_info, disable_http_all_file_handlers=True
289
+ http_info=_http_info,
290
+ request_id=_http_info.get("request_id", "-"),
291
+ disable_http_all_file_handlers=True,
288
292
  ).debug(_debug_msg)
289
293
  # await run_in_threadpool(
290
294
  # _logger.bind(
@@ -327,7 +331,9 @@ class HttpAccessLogMiddleware(BaseHTTPMiddleware):
327
331
  )
328
332
 
329
333
  _msg = _msg_format_str.format(**_http_info)
330
- _logger.bind(http_info=_http_info).log(_LEVEL, _msg)
334
+ _logger.bind(
335
+ http_info=_http_info, request_id=_http_info.get("request_id", "-")
336
+ ).log(_LEVEL, _msg)
331
337
  # await run_in_threadpool(_logger.bind(http_info=_http_info).log, _LEVEL, _msg)
332
338
  # Http access log.
333
339
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beans_logging_fastapi
3
- Version: 6.0.4
3
+ Version: 7.0.0
4
4
  Summary: This is a HTTP access log module for FastAPI based on 'beans-logging' package.
5
5
  Author-email: Batkhuu Byambajav <batkhuu10@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/bybatkhuu/module-fastapi-logging
@@ -22,7 +22,7 @@ Requires-Python: <4.0,>=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE.txt
24
24
  Requires-Dist: fastapi<1.0.0,>=0.99.1
25
- Requires-Dist: beans-logging<12.0.0,>=11.0.2
25
+ Requires-Dist: beans-logging<13.0.0,>=12.0.0
26
26
  Provides-Extra: test
27
27
  Requires-Dist: pytest<10.0.0,>=8.0.2; extra == "test"
28
28
  Requires-Dist: pytest-cov<8.0.0,>=5.0.0; extra == "test"
@@ -170,29 +170,36 @@ logger:
170
170
  app_name: "fastapi-app"
171
171
  level:
172
172
  base: TRACE
173
+ default_format: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
173
174
  http:
174
175
  std:
175
- format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
176
- err_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
177
- debug_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
176
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
177
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
178
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
178
179
  file:
179
180
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
180
181
  tz: "localtime"
181
- has_proxy_headers: true
182
- has_cf_headers: true
182
+ has_proxy_headers: false
183
+ has_cf_headers: false
183
184
  intercept:
184
185
  mute_modules: ["uvicorn.access"]
185
186
  handlers:
186
- http.access.file_handler:
187
+ std_handler:
188
+ enabled: true
189
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
190
+ http_access_std_handler:
191
+ enabled: true
192
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
193
+ http_access_file_handler:
187
194
  enabled: true
188
195
  sink: "http/{app_name}.http-access.log"
189
- http.err.file_handler:
196
+ http_err_file_handler:
190
197
  enabled: true
191
198
  sink: "http/{app_name}.http-err.log"
192
- http.access.json_handler:
199
+ http_access_json_handler:
193
200
  enabled: true
194
201
  sink: "http.json/{app_name}.http-access.json.log"
195
- http.err.json_handler:
202
+ http_err_json_handler:
196
203
  enabled: true
197
204
  sink: "http.json/{app_name}.http-err.json.log"
198
205
  ```
@@ -410,24 +417,25 @@ uvicorn main:app --host=0.0.0.0 --port=8000
410
417
  **Output**:
411
418
 
412
419
  ```txt
413
- [2026-01-01 12:00:00.002 +09:00 | TRACE | beans_logging.intercepters:96]: Intercepted modules: ['uvicorn', 'potato_util', 'fastapi', 'uvicorn.error', 'watchfiles.watcher', 'concurrent.futures', 'watchfiles', 'asyncio', 'concurrent', 'potato_util._base', 'dotenv', 'dotenv.main', 'watchfiles.main', 'potato_util.io', 'potato_util.io._sync']; Muted modules: ['uvicorn.access'];
414
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.server:84]: Started server process [88375]
415
- [2026-01-01 12:00:00.003 +09:00 | INFO | uvicorn.lifespan.on:48]: Waiting for application startup.
416
- [2026-01-01 12:00:00.004 +09:00 | TRACE | lifespan:19]: TRACE diagnosis is ON!
417
- [2026-01-01 12:00:00.004 +09:00 | DEBUG | lifespan:20]: DEBUG mode is ON!
418
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:21]: Preparing to startup...
419
- [2026-01-01 12:00:00.004 +09:00 | OK | lifespan:24]: Finished preparation to startup.
420
- [2026-01-01 12:00:00.004 +09:00 | INFO | lifespan:25]: Version: 0.0.0
421
- [2026-01-01 12:00:00.005 +09:00 | INFO | uvicorn.lifespan.on:62]: Application startup complete.
422
- [2026-01-01 12:00:00.006 +09:00 | INFO | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
423
- [2026-01-01 12:00:01.775 +09:00 | DEBUG ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1"
424
- [2026-01-01 12:00:01.783 +09:00 | OK ]: [80138308bc00406387fb804cf6cc0e11] 127.0.0.1 - "GET / HTTP/1.1" 200 17B 5.7ms
425
- ^C[2026-01-01 12:00:02.368 +09:00 | INFO | uvicorn.server:264]: Shutting down
426
- [2026-01-01 12:00:02.470 +09:00 | INFO | uvicorn.lifespan.on:67]: Waiting for application shutdown.
427
- [2026-01-01 12:00:02.472 +09:00 | INFO | lifespan:29]: Preparing to shutdown...
428
- [2026-01-01 12:00:02.472 +09:00 | OK | lifespan:31]: Finished preparation to shutdown.
429
- [2026-01-01 12:00:02.473 +09:00 | INFO | uvicorn.lifespan.on:76]: Application shutdown complete.
430
- [2026-01-01 12:00:02.474 +09:00 | INFO | uvicorn.server:94]: Finished server process [88375]
420
+ [2026-06-05 00:55:29.335 +09:00 | TRACE | - | beans_logging.intercepters:96]: Intercepted modules: ['potato_util', 'dotenv.main', 'concurrent', 'potato_util.io', 'asyncio', 'fastapi', 'concurrent.futures', 'dotenv', 'uvicorn', 'watchfiles.watcher', 'potato_util.io._sync', 'watchfiles.main', 'potato_util._base', 'uvicorn.error', 'watchfiles']; Muted modules: ['uvicorn.access'];
421
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.server:84]: Started server process [95017]
422
+ [2026-06-05 00:55:29.336 +09:00 | INFO | - | uvicorn.lifespan.on:48]: Waiting for application startup.
423
+ [2026-06-05 00:55:29.337 +09:00 | TRACE | - | lifespan:19]: TRACE diagnosis is ON!
424
+ [2026-06-05 00:55:29.337 +09:00 | DEBUG | - | lifespan:20]: DEBUG mode is ON!
425
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:21]: Preparing to startup...
426
+ [2026-06-05 00:55:29.337 +09:00 | OK | - | lifespan:24]: Finished preparation to startup.
427
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | lifespan:25]: Version: 0.0.0
428
+ [2026-06-05 00:55:29.337 +09:00 | INFO | - | uvicorn.lifespan.on:62]: Application startup complete.
429
+ [2026-06-05 00:55:29.339 +09:00 | INFO | - | uvicorn.server:216]: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
430
+ [2026-06-05 00:55:33.367 +09:00 | DEBUG | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1"
431
+ [2026-06-05 00:55:33.370 +09:00 | INFO | 58c916d045844314bb6c10b390ad5593 | router:11]: Root endpoint accessed.
432
+ [2026-06-05 00:55:33.371 +09:00 | OK | 58c916d045844314bb6c10b390ad5593]: 127.0.0.1 - "GET / HTTP/1.1" 200 17B 3.0ms
433
+ ^C[2026-06-05 00:55:35.702 +09:00 | INFO | - | uvicorn.server:264]: Shutting down
434
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:67]: Waiting for application shutdown.
435
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | lifespan:29]: Preparing to shutdown...
436
+ [2026-06-05 00:55:35.805 +09:00 | OK | - | lifespan:31]: Finished preparation to shutdown.
437
+ [2026-06-05 00:55:35.805 +09:00 | INFO | - | uvicorn.lifespan.on:76]: Application shutdown complete.
438
+ [2026-06-05 00:55:35.806 +09:00 | INFO | - | uvicorn.server:94]: Finished server process [95017]
431
439
  ```
432
440
 
433
441
  👍
@@ -444,19 +452,19 @@ logger:
444
452
  level:
445
453
  base: INFO
446
454
  err: WARNING
447
- format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line}]: {message}"
455
+ format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line} | {extra[request_id]}]: {message}"
448
456
  file:
449
457
  logs_dir: "./logs"
450
458
  rotate_size: 10000000
451
459
  rotate_time: "00:00:00"
452
460
  retention: 90
453
461
  encoding: utf8
454
- use_custom_serialize: false
462
+ custom_serialize: false
455
463
  http:
456
464
  std:
457
- msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
458
- err_msg_format_str: '<n><w>[{request_id}]</w></n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
459
- debug_msg_format_str: '<n>[{request_id}]</n> {client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
465
+ msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" {status_code} {content_length}B {response_time}ms'
466
+ err_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}" <n>{status_code}</n>'
467
+ debug_msg_format_str: '{client_host} {user_id} "<u>{method} {url_path}</u> HTTP/{http_version}"'
460
468
  file:
461
469
  format_str: '{client_host} {request_id} {user_id} [{datetime}] "{method} {url_path} HTTP/{http_version}" {status_code} {content_length} "{h_referer}" "{h_user_agent}" {response_time}'
462
470
  tz: localtime
@@ -468,53 +476,57 @@ logger:
468
476
  ignore_modules: []
469
477
  include_modules: []
470
478
  mute_modules: [uvicorn.access]
479
+ global_extra:
480
+ trace_id: "-"
481
+ request_id: "-"
482
+ user_id: "-"
471
483
  handlers:
472
484
  std_handler:
473
485
  enabled: true
474
- h_type: STD
475
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
486
+ type_: STD
487
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w> | <w>{name}:{line}</w>]: <level>{message}</level>"
476
488
  colorize: true
477
489
  file_handler:
478
490
  enabled: true
479
- h_type: FILE
491
+ type_: FILE
480
492
  sink: "{app_name}.all.log"
481
493
  err_file_handler:
482
494
  enabled: true
483
- h_type: FILE
495
+ type_: FILE
484
496
  sink: "{app_name}.err.log"
485
497
  error: true
486
498
  json_handler:
487
499
  enabled: true
488
- h_type: FILE
500
+ type_: FILE
489
501
  sink: "json/{app_name}.all.json.log"
490
502
  serialize: true
491
503
  err_json_handler:
492
504
  enabled: true
493
- h_type: FILE
505
+ type_: FILE
494
506
  sink: "json/{app_name}.err.json.log"
495
507
  serialize: true
496
508
  error: true
497
509
  http_access_std_handler:
498
510
  enabled: true
499
- h_type: STD
500
- format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> ]: <level>{message}</level>"
511
+ type_: STD
512
+ format: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{extra[request_id]}</w>]: <level>{message}</level>"
501
513
  colorize: true
502
514
  http_access_file_handler:
503
515
  enabled: true
504
- h_type: FILE
516
+ type_: FILE
505
517
  sink: "http/{app_name}.http-access.log"
506
518
  http_err_file_handler:
507
519
  enabled: true
508
- h_type: FILE
520
+ type_: FILE
509
521
  sink: "http/{app_name}.http-err.log"
510
522
  error: true
511
523
  http_access_json_handler:
512
524
  enabled: true
513
- h_type: FILE
525
+ type_: FILE
514
526
  sink: "http.json/{app_name}.http-access.json.log"
515
527
  http_err_json_handler:
516
528
  enabled: true
517
- h_type: FILE
529
+ type_: FILE
518
530
  sink: "http.json/{app_name}.http-err.json.log"
519
531
  error: true
520
532
  extra:
@@ -1,5 +1,5 @@
1
1
  fastapi<1.0.0,>=0.99.1
2
- beans-logging<12.0.0,>=11.0.2
2
+ beans-logging<13.0.0,>=12.0.0
3
3
 
4
4
  [build]
5
5
  setuptools<83.0.0,>=70.3.0
@@ -1,2 +0,0 @@
1
- fastapi>=0.99.1,<1.0.0
2
- beans-logging>=11.0.2,<12.0.0
@@ -1 +0,0 @@
1
- __version__ = "6.0.4"