beans-logging-fastapi 5.2.1__tar.gz → 6.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.
- {beans_logging_fastapi-5.2.1/src/beans_logging_fastapi.egg-info → beans_logging_fastapi-6.0.0}/PKG-INFO +5 -5
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/README.md +3 -3
- beans_logging_fastapi-6.0.0/requirements.txt +2 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/__init__.py +4 -1
- beans_logging_fastapi-6.0.0/src/beans_logging_fastapi/__version__.py +1 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/middlewares.py +1 -3
- beans_logging_fastapi-6.0.0/src/beans_logging_fastapi/mode.py +44 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0/src/beans_logging_fastapi.egg-info}/PKG-INFO +5 -5
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi.egg-info/SOURCES.txt +1 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi.egg-info/requires.txt +1 -1
- beans_logging_fastapi-5.2.1/requirements.txt +0 -2
- beans_logging_fastapi-5.2.1/src/beans_logging_fastapi/__version__.py +0 -1
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/.python-version +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/LICENSE.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/pyproject.toml +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.build.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.dev.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.docs.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.test.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/setup.cfg +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/setup.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/_async.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/_core.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/config.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/constants.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/filters.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/formats.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/http_error.py +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi.egg-info/dependency_links.txt +0 -0
- {beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.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:
|
|
3
|
+
Version: 6.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<
|
|
25
|
+
Requires-Dist: beans-logging<12.0.0,>=11.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"
|
|
@@ -467,12 +467,12 @@ logger:
|
|
|
467
467
|
include_modules: []
|
|
468
468
|
mute_modules: [uvicorn.access]
|
|
469
469
|
handlers:
|
|
470
|
-
|
|
470
|
+
std_handler:
|
|
471
471
|
enabled: true
|
|
472
472
|
h_type: STD
|
|
473
473
|
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>"
|
|
474
474
|
colorize: true
|
|
475
|
-
|
|
475
|
+
file_handler:
|
|
476
476
|
enabled: true
|
|
477
477
|
h_type: FILE
|
|
478
478
|
sink: "{app_name}.all.log"
|
|
@@ -481,7 +481,7 @@ logger:
|
|
|
481
481
|
h_type: FILE
|
|
482
482
|
sink: "{app_name}.err.log"
|
|
483
483
|
error: true
|
|
484
|
-
|
|
484
|
+
json_handler:
|
|
485
485
|
enabled: true
|
|
486
486
|
h_type: FILE
|
|
487
487
|
sink: "json/{app_name}.all.json.log"
|
|
@@ -407,12 +407,12 @@ logger:
|
|
|
407
407
|
include_modules: []
|
|
408
408
|
mute_modules: [uvicorn.access]
|
|
409
409
|
handlers:
|
|
410
|
-
|
|
410
|
+
std_handler:
|
|
411
411
|
enabled: true
|
|
412
412
|
h_type: STD
|
|
413
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>"
|
|
414
414
|
colorize: true
|
|
415
|
-
|
|
415
|
+
file_handler:
|
|
416
416
|
enabled: true
|
|
417
417
|
h_type: FILE
|
|
418
418
|
sink: "{app_name}.all.log"
|
|
@@ -421,7 +421,7 @@ logger:
|
|
|
421
421
|
h_type: FILE
|
|
422
422
|
sink: "{app_name}.err.log"
|
|
423
423
|
error: true
|
|
424
|
-
|
|
424
|
+
json_handler:
|
|
425
425
|
enabled: true
|
|
426
426
|
h_type: FILE
|
|
427
427
|
sink: "json/{app_name}.all.json.log"
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/__init__.py
RENAMED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
from beans_logging import logger
|
|
1
|
+
from beans_logging import logger, LogLevelEnum
|
|
2
2
|
|
|
3
3
|
from .__version__ import __version__
|
|
4
4
|
from .config import LoggerConfigPM
|
|
5
5
|
from ._core import add_logger
|
|
6
6
|
from .http_error import async_log_http_error, log_http_error
|
|
7
|
+
from .mode import async_log_at
|
|
7
8
|
|
|
8
9
|
__all__ = [
|
|
9
10
|
"__version__",
|
|
10
11
|
"logger",
|
|
12
|
+
"LogLevelEnum",
|
|
11
13
|
"add_logger",
|
|
12
14
|
"LoggerConfigPM",
|
|
13
15
|
"async_log_http_error",
|
|
14
16
|
"log_http_error",
|
|
17
|
+
"async_log_at",
|
|
15
18
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "6.0.0"
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/middlewares.py
RENAMED
|
@@ -271,9 +271,7 @@ class HttpAccessLogMiddleware(BaseHTTPMiddleware):
|
|
|
271
271
|
self.use_debug_log = use_debug_log
|
|
272
272
|
|
|
273
273
|
async def dispatch(self, request: Request, call_next) -> Response:
|
|
274
|
-
_logger = logger.opt(colors=True, record=True).bind(
|
|
275
|
-
disable_all_std_handler=True
|
|
276
|
-
)
|
|
274
|
+
_logger = logger.opt(colors=True, record=True).bind(disable_std_handler=True)
|
|
277
275
|
|
|
278
276
|
_http_info: dict[str, Any] = {}
|
|
279
277
|
if hasattr(request.state, "http_info") and isinstance(
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from pydantic import validate_call
|
|
2
|
+
from fastapi.concurrency import run_in_threadpool
|
|
3
|
+
|
|
4
|
+
from potato_util.constants import WarnEnum
|
|
5
|
+
from beans_logging.constants import LogLevelEnum
|
|
6
|
+
from beans_logging import logger
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@validate_call
|
|
10
|
+
async def async_log_at(
|
|
11
|
+
message: str,
|
|
12
|
+
level: LogLevelEnum | str = LogLevelEnum.INFO,
|
|
13
|
+
warn_mode: WarnEnum | str = WarnEnum.ALWAYS,
|
|
14
|
+
) -> None:
|
|
15
|
+
"""Log message with level and warn mode in async context.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
message (str , required): Message to log.
|
|
19
|
+
level (LogLevelEnum | str, optional): Log level when warn mode is `WarnEnum.ALWAYS`.
|
|
20
|
+
Defaults to `LogLevelEnum.INFO`.
|
|
21
|
+
warn_mode (WarnEnum | str , optional): Warn mode to use. Defaults to `WarnEnum.ALWAYS`.
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
ValueError: If `level` is not a valid log level.
|
|
25
|
+
ValueError: If `warn_mode` is not a valid warn mode.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
if isinstance(level, str):
|
|
29
|
+
level = LogLevelEnum(level.strip().upper())
|
|
30
|
+
|
|
31
|
+
if isinstance(warn_mode, str):
|
|
32
|
+
warn_mode = WarnEnum(warn_mode.strip().upper())
|
|
33
|
+
|
|
34
|
+
if warn_mode == WarnEnum.ALWAYS:
|
|
35
|
+
await run_in_threadpool(logger.log, level.name, message)
|
|
36
|
+
elif warn_mode == WarnEnum.DEBUG:
|
|
37
|
+
await run_in_threadpool(logger.debug, message)
|
|
38
|
+
|
|
39
|
+
return
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"async_log_at",
|
|
44
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beans_logging_fastapi
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.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<
|
|
25
|
+
Requires-Dist: beans-logging<12.0.0,>=11.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"
|
|
@@ -467,12 +467,12 @@ logger:
|
|
|
467
467
|
include_modules: []
|
|
468
468
|
mute_modules: [uvicorn.access]
|
|
469
469
|
handlers:
|
|
470
|
-
|
|
470
|
+
std_handler:
|
|
471
471
|
enabled: true
|
|
472
472
|
h_type: STD
|
|
473
473
|
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>"
|
|
474
474
|
colorize: true
|
|
475
|
-
|
|
475
|
+
file_handler:
|
|
476
476
|
enabled: true
|
|
477
477
|
h_type: FILE
|
|
478
478
|
sink: "{app_name}.all.log"
|
|
@@ -481,7 +481,7 @@ logger:
|
|
|
481
481
|
h_type: FILE
|
|
482
482
|
sink: "{app_name}.err.log"
|
|
483
483
|
error: true
|
|
484
|
-
|
|
484
|
+
json_handler:
|
|
485
485
|
enabled: true
|
|
486
486
|
h_type: FILE
|
|
487
487
|
sink: "json/{app_name}.all.json.log"
|
|
@@ -24,6 +24,7 @@ src/beans_logging_fastapi/filters.py
|
|
|
24
24
|
src/beans_logging_fastapi/formats.py
|
|
25
25
|
src/beans_logging_fastapi/http_error.py
|
|
26
26
|
src/beans_logging_fastapi/middlewares.py
|
|
27
|
+
src/beans_logging_fastapi/mode.py
|
|
27
28
|
src/beans_logging_fastapi.egg-info/PKG-INFO
|
|
28
29
|
src/beans_logging_fastapi.egg-info/SOURCES.txt
|
|
29
30
|
src/beans_logging_fastapi.egg-info/dependency_links.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "5.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.build.txt
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.dev.txt
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.docs.txt
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/requirements/requirements.test.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/_async.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/_core.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/config.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/constants.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/filters.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/formats.py
RENAMED
|
File without changes
|
{beans_logging_fastapi-5.2.1 → beans_logging_fastapi-6.0.0}/src/beans_logging_fastapi/http_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|