beans-logging-fastapi 2.0.0__py3-none-any.whl → 4.0.0__py3-none-any.whl
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/__init__.py +6 -24
- beans_logging_fastapi/__version__.py +1 -1
- beans_logging_fastapi/{_async_log.py → _async.py} +7 -7
- beans_logging_fastapi/_core.py +93 -0
- beans_logging_fastapi/config.py +177 -0
- beans_logging_fastapi/constants.py +23 -0
- beans_logging_fastapi/filters.py +72 -0
- beans_logging_fastapi/{_formats.py → formats.py} +7 -7
- beans_logging_fastapi/{_middlewares.py → middlewares.py} +109 -0
- {beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/METADATA +241 -147
- beans_logging_fastapi-4.0.0.dist-info/RECORD +14 -0
- {beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/WHEEL +1 -1
- beans_logging_fastapi/_base.py +0 -107
- beans_logging_fastapi/_filters.py +0 -30
- beans_logging_fastapi/_handlers.py +0 -96
- beans_logging_fastapi-2.0.0.dist-info/RECORD +0 -13
- {beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING
|
|
2
|
-
|
|
3
|
-
if TYPE_CHECKING:
|
|
4
|
-
from loguru import Record
|
|
5
|
-
|
|
6
|
-
from beans_logging.filters import use_all_filter
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def use_http_filter(record: "Record") -> bool:
|
|
10
|
-
"""Filter message only for http access log handler by checking 'http_info' key in extra.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
record (Record, required): Log record as dictionary.
|
|
14
|
-
|
|
15
|
-
Returns:
|
|
16
|
-
bool: True if record has 'http_info' key in extra, False otherwise.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
if not use_all_filter(record):
|
|
20
|
-
return False
|
|
21
|
-
|
|
22
|
-
if "http_info" not in record["extra"]:
|
|
23
|
-
return False
|
|
24
|
-
|
|
25
|
-
return True
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
__all__ = [
|
|
29
|
-
"use_http_filter",
|
|
30
|
-
]
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
from collections.abc import Callable
|
|
2
|
-
|
|
3
|
-
from pydantic import validate_call
|
|
4
|
-
|
|
5
|
-
from beans_logging import LoggerLoader
|
|
6
|
-
|
|
7
|
-
from ._filters import use_http_filter
|
|
8
|
-
from ._formats import http_file_format, http_file_json_format
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@validate_call(config={"arbitrary_types_allowed": True})
|
|
12
|
-
def add_http_file_handler(
|
|
13
|
-
logger_loader: LoggerLoader,
|
|
14
|
-
log_path: str = "http/{app_name}.http.access.log",
|
|
15
|
-
err_path: str = "http/{app_name}.http.err.log",
|
|
16
|
-
formatter: Callable | str = http_file_format,
|
|
17
|
-
) -> None:
|
|
18
|
-
"""Add http access log file and error file handler.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
logger_loader (LoggerLoader, required): LoggerLoader instance.
|
|
22
|
-
log_path (str, optional): Log file path. Defaults to "http/{app_name}.http.access.log".
|
|
23
|
-
err_path (str, optional): Error log file path. Defaults to "http/{app_name}.http.err.log".
|
|
24
|
-
formatter (Union[Callable, str], optional): Log formatter. Defaults to `http_file_format` function.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
logger_loader.add_handler(
|
|
28
|
-
name="default.http.access.file_handler",
|
|
29
|
-
handler={
|
|
30
|
-
"type": "FILE",
|
|
31
|
-
"sink": log_path,
|
|
32
|
-
"filter": use_http_filter,
|
|
33
|
-
"format": formatter,
|
|
34
|
-
},
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
logger_loader.add_handler(
|
|
38
|
-
name="default.http.err.file_handler",
|
|
39
|
-
handler={
|
|
40
|
-
"type": "FILE",
|
|
41
|
-
"sink": err_path,
|
|
42
|
-
"filter": use_http_filter,
|
|
43
|
-
"format": formatter,
|
|
44
|
-
"error": True,
|
|
45
|
-
},
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@validate_call(config={"arbitrary_types_allowed": True})
|
|
52
|
-
def add_http_file_json_handler(
|
|
53
|
-
logger_loader: LoggerLoader,
|
|
54
|
-
log_path: str = "http.json/{app_name}.http.json.access.log",
|
|
55
|
-
err_path: str = "http.json/{app_name}.http.json.err.log",
|
|
56
|
-
formatter: Callable | str = http_file_json_format,
|
|
57
|
-
) -> None:
|
|
58
|
-
"""Add http access json log file and json error file handler.
|
|
59
|
-
|
|
60
|
-
Args:
|
|
61
|
-
logger_loader (LoggerLoader, required): LoggerLoader instance.
|
|
62
|
-
log_path (str, optional): Json log file path. Defaults to
|
|
63
|
-
"http.json/{app_name}.http.json.access.log".
|
|
64
|
-
err_path (str, optional): Json error log file path. Defaults to
|
|
65
|
-
"http.json/{app_name}.http.json.err.log".
|
|
66
|
-
formatter (Union[Callable, str], optional): Log formatter. Defaults to `http_file_json_format` function.
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
logger_loader.add_handler(
|
|
70
|
-
name="default.http.access.json_handler",
|
|
71
|
-
handler={
|
|
72
|
-
"type": "FILE",
|
|
73
|
-
"sink": log_path,
|
|
74
|
-
"filter": use_http_filter,
|
|
75
|
-
"format": formatter,
|
|
76
|
-
},
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
logger_loader.add_handler(
|
|
80
|
-
name="default.http.err.json_handler",
|
|
81
|
-
handler={
|
|
82
|
-
"type": "FILE",
|
|
83
|
-
"sink": err_path,
|
|
84
|
-
"filter": use_http_filter,
|
|
85
|
-
"format": formatter,
|
|
86
|
-
"error": True,
|
|
87
|
-
},
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
__all__ = [
|
|
94
|
-
"add_http_file_handler",
|
|
95
|
-
"add_http_file_json_handler",
|
|
96
|
-
]
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
beans_logging_fastapi/__init__.py,sha256=hTuW6GTdPinZ1qamna7N0RsElfVJnkkOI0iLnMbQ7B8,865
|
|
2
|
-
beans_logging_fastapi/__version__.py,sha256=_7OlQdbVkK4jad0CLdpI0grT-zEAb-qgFmH5mFzDXiA,22
|
|
3
|
-
beans_logging_fastapi/_async_log.py,sha256=01VJ1cnzacDlIjiScm0hubhkj0xkeU5pBB_0fPJS-5w,3478
|
|
4
|
-
beans_logging_fastapi/_base.py,sha256=mRAUxEBYU00IrE4QgaYDqrUxHhCiKp3cEzVNy2bDsM0,4259
|
|
5
|
-
beans_logging_fastapi/_filters.py,sha256=hBhHqCWJr7c2CA7uDAje8R8x9RtpCcBHZSC6xuXLYDs,622
|
|
6
|
-
beans_logging_fastapi/_formats.py,sha256=J5tu9QwU6jCNZvMt7y5WpfcM862GLvgGHGfvjh5k2T4,2600
|
|
7
|
-
beans_logging_fastapi/_handlers.py,sha256=_v4VigZM2j1kphUPViKp21DiwR3CB1mM6MXz_NUAE7c,3128
|
|
8
|
-
beans_logging_fastapi/_middlewares.py,sha256=gcx8NrgWv1OMFln4nvnaPgY6Np92Nv6OTMJf97EcH08,9558
|
|
9
|
-
beans_logging_fastapi-2.0.0.dist-info/licenses/LICENSE.txt,sha256=CUTK-r0BWIg1r0bBiemAcMhakgV0N7HuRhw6rQ-A9A4,1074
|
|
10
|
-
beans_logging_fastapi-2.0.0.dist-info/METADATA,sha256=aM3l5OHfrFiy1RYGOYHmOMl7fG0iTGmgXd1tV1F6oLQ,16031
|
|
11
|
-
beans_logging_fastapi-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
-
beans_logging_fastapi-2.0.0.dist-info/top_level.txt,sha256=PXoqVo9HGfyd81gDi3D2mXMYPM9JKITL0ycFftJxlhw,22
|
|
13
|
-
beans_logging_fastapi-2.0.0.dist-info/RECORD,,
|
{beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|
{beans_logging_fastapi-2.0.0.dist-info → beans_logging_fastapi-4.0.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|