beans-logging 6.0.2__py3-none-any.whl → 7.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/__init__.py +6 -6
- beans_logging/__version__.py +1 -1
- beans_logging/_builder.py +154 -0
- beans_logging/_constants.py +30 -0
- beans_logging/_core.py +295 -0
- beans_logging/_intercept.py +106 -0
- beans_logging/auto.py +3 -12
- beans_logging/config.py +186 -0
- beans_logging/filters.py +37 -20
- beans_logging/formats.py +20 -4
- beans_logging/{rotation.py → rotators.py} +20 -14
- beans_logging/schemas.py +129 -159
- beans_logging/sinks.py +11 -2
- {beans_logging-6.0.2.dist-info → beans_logging-7.0.0.dist-info}/METADATA +80 -61
- beans_logging-7.0.0.dist-info/RECORD +18 -0
- beans_logging/_base.py +0 -660
- beans_logging/_consts.py +0 -18
- beans_logging/_handlers.py +0 -40
- beans_logging/_utils.py +0 -99
- beans_logging-6.0.2.dist-info/RECORD +0 -17
- {beans_logging-6.0.2.dist-info → beans_logging-7.0.0.dist-info}/WHEEL +0 -0
- {beans_logging-6.0.2.dist-info → beans_logging-7.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {beans_logging-6.0.2.dist-info → beans_logging-7.0.0.dist-info}/top_level.txt +0 -0
beans_logging/schemas.py
CHANGED
|
@@ -1,173 +1,143 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import inspect
|
|
1
4
|
import datetime
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from logging import Handler
|
|
7
|
+
from asyncio import AbstractEventLoop
|
|
8
|
+
from multiprocessing.context import BaseContext
|
|
9
|
+
from typing import TYPE_CHECKING, Any, TextIO, Union, Protocol, runtime_checkable
|
|
10
|
+
from collections.abc import Callable, Awaitable
|
|
11
|
+
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import Self
|
|
9
14
|
else:
|
|
10
|
-
from
|
|
15
|
+
from typing_extensions import Self
|
|
11
16
|
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
from
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from loguru import Record, Message
|
|
20
|
+
from pydantic import BaseModel, Field, ConfigDict, model_validator
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
class ExtraBaseModel(BaseModel):
|
|
18
|
-
if "2.0.0" <= pydantic.__version__:
|
|
19
|
-
model_config = ConfigDict(extra="allow")
|
|
20
|
-
else:
|
|
21
|
-
|
|
22
|
-
class Config:
|
|
23
|
-
extra = "allow"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class StdHandlerPM(ExtraBaseModel):
|
|
27
|
-
enabled: bool = Field(default=True)
|
|
22
|
+
from ._constants import LogHandlerTypeEnum, LogLevelEnum
|
|
28
23
|
|
|
29
24
|
|
|
30
|
-
class
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
max_length=511,
|
|
25
|
+
class ExtraBaseModel(BaseModel):
|
|
26
|
+
model_config = ConfigDict(
|
|
27
|
+
extra="allow",
|
|
28
|
+
validate_default=True,
|
|
29
|
+
validate_assignment=True,
|
|
30
|
+
populate_by_name=True, # Remove in Pydantic v3
|
|
31
|
+
serialize_by_alias=True,
|
|
32
|
+
validate_by_name=True,
|
|
33
|
+
arbitrary_types_allowed=True,
|
|
40
34
|
)
|
|
41
|
-
std_handler: StdHandlerPM = Field(default_factory=StdHandlerPM)
|
|
42
|
-
|
|
43
35
|
|
|
44
|
-
class LogHandlersPM(ExtraBaseModel):
|
|
45
|
-
enabled: bool = Field(default=False)
|
|
46
|
-
format_str: constr(strip_whitespace=True) = Field(
|
|
47
|
-
default="[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {level_short:<5} | {name}:{line}]: {message}",
|
|
48
|
-
min_length=4,
|
|
49
|
-
max_length=511,
|
|
50
|
-
)
|
|
51
|
-
log_path: constr(strip_whitespace=True) = Field(
|
|
52
|
-
default="{app_name}.std.all.log", min_length=4, max_length=1023
|
|
53
|
-
)
|
|
54
|
-
err_path: constr(strip_whitespace=True) = Field(
|
|
55
|
-
default="{app_name}.std.err.log", min_length=4, max_length=1023
|
|
56
|
-
)
|
|
57
36
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
37
|
+
@runtime_checkable
|
|
38
|
+
class _SupportsWrite(Protocol):
|
|
39
|
+
def write(self, __s: str) -> Any: ...
|
|
40
|
+
def flush(self) -> Any: ...
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
_SinkType = Union[
|
|
44
|
+
str,
|
|
45
|
+
Path,
|
|
46
|
+
TextIO,
|
|
47
|
+
_SupportsWrite,
|
|
48
|
+
Callable[[Any], Any],
|
|
49
|
+
Callable[[Any], Awaitable[Any]],
|
|
50
|
+
Handler,
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class LoguruHandlerPM(ExtraBaseModel):
|
|
55
|
+
sink: _SinkType = Field(...)
|
|
56
|
+
level: str | int | None = Field(default=None)
|
|
57
|
+
format_: (
|
|
58
|
+
str | Callable[["Record"], str] | Callable[[dict[str, Any]], str] | None
|
|
59
|
+
) = Field(default=None, validation_alias="format", serialization_alias="format")
|
|
60
|
+
filter_: (
|
|
61
|
+
Callable[["Record"], bool]
|
|
62
|
+
| Callable[[dict[str, Any]], bool]
|
|
63
|
+
| str
|
|
64
|
+
| dict[str, Any]
|
|
65
|
+
| None
|
|
66
|
+
) = Field(default=None, validation_alias="filter", serialization_alias="filter")
|
|
67
|
+
colorize: bool | None = Field(default=None)
|
|
68
|
+
serialize: bool | None = Field(default=None)
|
|
69
|
+
backtrace: bool | None = Field(default=None)
|
|
70
|
+
diagnose: bool | None = Field(default=None)
|
|
71
|
+
enqueue: bool | None = Field(default=None)
|
|
72
|
+
context: BaseContext | str | None = Field(default=None)
|
|
73
|
+
catch: bool | None = Field(default=None)
|
|
74
|
+
loop: AbstractEventLoop | None = Field(default=None)
|
|
75
|
+
rotation: (
|
|
76
|
+
str
|
|
77
|
+
| int
|
|
78
|
+
| datetime.time
|
|
79
|
+
| datetime.timedelta
|
|
80
|
+
| Callable[["Message", TextIO], bool]
|
|
81
|
+
| Callable[[str, TextIO], bool]
|
|
82
|
+
| Callable[[str, Any], bool]
|
|
83
|
+
| None
|
|
84
|
+
) = Field(default=None)
|
|
85
|
+
retention: str | int | datetime.timedelta | Callable[[Any], None] | None = Field(
|
|
86
|
+
default=None
|
|
85
87
|
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
compression: str | Callable[[str], None] | None = Field(default=None)
|
|
89
|
+
delay: bool | None = Field(default=None)
|
|
90
|
+
watch: bool | None = Field(default=None)
|
|
91
|
+
mode: str | None = Field(default=None)
|
|
92
|
+
buffering: int | None = Field(default=None)
|
|
93
|
+
encoding: str | None = Field(default=None)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class LogHandlerPM(LoguruHandlerPM):
|
|
97
|
+
type_: LogHandlerTypeEnum = Field(
|
|
98
|
+
default=LogHandlerTypeEnum.UNKNOWN,
|
|
99
|
+
validation_alias="type",
|
|
100
|
+
serialization_alias="type",
|
|
88
101
|
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def _check_log_path(self) -> "JsonHandlersPM":
|
|
94
|
-
if self.log_path == self.err_path:
|
|
95
|
-
raise ValueError(
|
|
96
|
-
f"`log_path` and `err_path` attributes are same: '{self.log_path}', must be different!"
|
|
97
|
-
)
|
|
98
|
-
return self
|
|
99
|
-
|
|
100
|
-
else:
|
|
101
|
-
|
|
102
|
-
@root_validator
|
|
103
|
-
def _check_log_path(cls, values):
|
|
104
|
-
_log_path, _err_path = values.get("log_path"), values.get("err_path")
|
|
105
|
-
if _log_path == _err_path:
|
|
106
|
-
raise ValueError(
|
|
107
|
-
f"`log_path` and `err_path` attributes are same: '{_log_path}', must be different!"
|
|
108
|
-
)
|
|
109
|
-
return values
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
class FilePM(ExtraBaseModel):
|
|
113
|
-
logs_dir: constr(strip_whitespace=True) = Field(
|
|
114
|
-
default_factory=get_default_logs_dir, min_length=2, max_length=1023
|
|
115
|
-
)
|
|
116
|
-
rotate_size: int = Field(
|
|
117
|
-
default=10_000_000, ge=1_000, lt=1_000_000_000 # 10MB = 10 * 1000 * 1000
|
|
118
|
-
)
|
|
119
|
-
rotate_time: datetime.time = Field(datetime.time(0, 0, 0))
|
|
120
|
-
backup_count: int = Field(default=90, ge=1)
|
|
121
|
-
encoding: constr(strip_whitespace=True) = Field(
|
|
122
|
-
default="utf8", min_length=2, max_length=31
|
|
123
|
-
)
|
|
124
|
-
log_handlers: LogHandlersPM = Field(default_factory=LogHandlersPM)
|
|
125
|
-
json_handlers: JsonHandlersPM = Field(default_factory=JsonHandlersPM)
|
|
126
|
-
|
|
127
|
-
if "2.0.0" <= pydantic.__version__:
|
|
128
|
-
|
|
129
|
-
@field_validator("rotate_time", mode="before")
|
|
130
|
-
@classmethod
|
|
131
|
-
def _check_rotate_time(cls, val):
|
|
132
|
-
if isinstance(val, str):
|
|
133
|
-
val = datetime.time.fromisoformat(val)
|
|
134
|
-
return val
|
|
135
|
-
|
|
136
|
-
else:
|
|
137
|
-
|
|
138
|
-
@validator("rotate_time", pre=True, always=True)
|
|
139
|
-
def _check_rotate_time(cls, val):
|
|
140
|
-
if val and isinstance(val, str):
|
|
141
|
-
val = datetime.time.fromisoformat(val)
|
|
142
|
-
return val
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
class AutoLoadPM(ExtraBaseModel):
|
|
102
|
+
sink: _SinkType | None = Field(default=None)
|
|
103
|
+
level: str | int | LogLevelEnum | None = Field(default=None)
|
|
104
|
+
custom_serialize: bool | None = Field(default=None)
|
|
105
|
+
error: bool = Field(default=False)
|
|
146
106
|
enabled: bool = Field(default=True)
|
|
147
|
-
only_base: bool = Field(default=False)
|
|
148
|
-
ignore_modules: list[str] = Field(default=[])
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
class InterceptPM(ExtraBaseModel):
|
|
152
|
-
auto_load: AutoLoadPM = Field(default_factory=AutoLoadPM)
|
|
153
|
-
include_modules: list[str] = Field(default=[])
|
|
154
|
-
mute_modules: list[str] = Field(default=[])
|
|
155
107
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
108
|
+
@model_validator(mode="after")
|
|
109
|
+
def _check_all(self) -> Self:
|
|
110
|
+
|
|
111
|
+
if (self.loop is not None) and (
|
|
112
|
+
(not callable(self.sink)) or (not inspect.iscoroutinefunction(self.sink))
|
|
113
|
+
):
|
|
114
|
+
raise ValueError(
|
|
115
|
+
f"'loop' attribute is set but 'sink' attribute type {type(self.sink)} is invalid, "
|
|
116
|
+
"'loop' only can be used with async callable (coroutine function) 'sink'!"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if not isinstance(self.sink, (str, os.PathLike)):
|
|
120
|
+
for _attr in (
|
|
121
|
+
"rotation",
|
|
122
|
+
"retention",
|
|
123
|
+
"compression",
|
|
124
|
+
"delay",
|
|
125
|
+
"watch",
|
|
126
|
+
"mode",
|
|
127
|
+
"buffering",
|
|
128
|
+
"encoding",
|
|
129
|
+
):
|
|
130
|
+
if getattr(self, _attr) is not None:
|
|
131
|
+
raise ValueError(
|
|
132
|
+
f"'{_attr}' attribute is set but 'sink' attribute type {type(self.sink).__name__} is invalid, "
|
|
133
|
+
f"'{_attr}' can only be used with file path 'sink'!"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return self
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
__all__ = [
|
|
140
|
+
"ExtraBaseModel",
|
|
141
|
+
"LoguruHandlerPM",
|
|
142
|
+
"LogHandlerPM",
|
|
143
|
+
]
|
beans_logging/sinks.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import sys
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from loguru import Message
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
def std_sink(message: Message):
|
|
8
|
+
def std_sink(message: "Message") -> None:
|
|
7
9
|
"""Print message based on log level to stdout or stderr.
|
|
8
10
|
|
|
9
11
|
Args:
|
|
@@ -12,5 +14,12 @@ def std_sink(message: Message):
|
|
|
12
14
|
|
|
13
15
|
if message.record["level"].no < 40:
|
|
14
16
|
sys.stdout.write(message)
|
|
17
|
+
# sys.stdout.flush()
|
|
15
18
|
else:
|
|
16
19
|
sys.stderr.write(message)
|
|
20
|
+
# sys.stderr.flush()
|
|
21
|
+
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = ["std_sink"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beans_logging
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
4
4
|
Summary: 'beans-logging' is a python package for simple logger and easily managing logs.
|
|
5
5
|
Author-email: Batkhuu Byambajav <batkhuu10@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/bybatkhuu/module-python-logging
|
|
@@ -21,13 +21,13 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
21
21
|
Requires-Python: <4.0,>=3.10
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE.txt
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist: pydantic[timezone]!=2.1.0,<3.0.0,>=2.0.3
|
|
24
|
+
Requires-Dist: pydantic[timezone]<3.0.0,>=2.5.3
|
|
26
25
|
Requires-Dist: loguru<1.0.0,>=0.7.3
|
|
26
|
+
Requires-Dist: potato_util<1.0.0,>=0.2.0
|
|
27
27
|
Provides-Extra: fastapi
|
|
28
28
|
Requires-Dist: beans-logging-fastapi<2.0.0,>=1.0.0; extra == "fastapi"
|
|
29
29
|
Provides-Extra: test
|
|
30
|
-
Requires-Dist: pytest<
|
|
30
|
+
Requires-Dist: pytest<10.0.0,>=8.0.2; extra == "test"
|
|
31
31
|
Requires-Dist: pytest-cov<8.0.0,>=5.0.0; extra == "test"
|
|
32
32
|
Requires-Dist: pytest-xdist<4.0.0,>=3.6.1; extra == "test"
|
|
33
33
|
Requires-Dist: pytest-benchmark<6.0.0,>=5.0.1; extra == "test"
|
|
@@ -37,13 +37,13 @@ Requires-Dist: wheel<1.0.0,>=0.43.0; extra == "build"
|
|
|
37
37
|
Requires-Dist: build<2.0.0,>=1.1.1; extra == "build"
|
|
38
38
|
Requires-Dist: twine<7.0.0,>=6.0.1; extra == "build"
|
|
39
39
|
Provides-Extra: docs
|
|
40
|
-
Requires-Dist: pylint<
|
|
40
|
+
Requires-Dist: pylint<5.0.0,>=3.0.4; extra == "docs"
|
|
41
41
|
Requires-Dist: mkdocs-material<10.0.0,>=9.5.50; extra == "docs"
|
|
42
42
|
Requires-Dist: mkdocs-awesome-nav<4.0.0,>=3.0.0; extra == "docs"
|
|
43
|
-
Requires-Dist: mkdocstrings[python]<
|
|
43
|
+
Requires-Dist: mkdocstrings[python]<2.0.0,>=0.24.3; extra == "docs"
|
|
44
44
|
Requires-Dist: mike<3.0.0,>=2.1.3; extra == "docs"
|
|
45
45
|
Provides-Extra: dev
|
|
46
|
-
Requires-Dist: pytest<
|
|
46
|
+
Requires-Dist: pytest<10.0.0,>=8.0.2; extra == "dev"
|
|
47
47
|
Requires-Dist: pytest-cov<8.0.0,>=5.0.0; extra == "dev"
|
|
48
48
|
Requires-Dist: pytest-xdist<4.0.0,>=3.6.1; extra == "dev"
|
|
49
49
|
Requires-Dist: pytest-benchmark<6.0.0,>=5.0.1; extra == "dev"
|
|
@@ -51,10 +51,10 @@ Requires-Dist: setuptools<81.0.0,>=70.3.0; extra == "dev"
|
|
|
51
51
|
Requires-Dist: wheel<1.0.0,>=0.43.0; extra == "dev"
|
|
52
52
|
Requires-Dist: build<2.0.0,>=1.1.1; extra == "dev"
|
|
53
53
|
Requires-Dist: twine<7.0.0,>=6.0.1; extra == "dev"
|
|
54
|
-
Requires-Dist: pylint<
|
|
54
|
+
Requires-Dist: pylint<5.0.0,>=3.0.4; extra == "dev"
|
|
55
55
|
Requires-Dist: mkdocs-material<10.0.0,>=9.5.50; extra == "dev"
|
|
56
56
|
Requires-Dist: mkdocs-awesome-nav<4.0.0,>=3.0.0; extra == "dev"
|
|
57
|
-
Requires-Dist: mkdocstrings[python]<
|
|
57
|
+
Requires-Dist: mkdocstrings[python]<2.0.0,>=0.24.3; extra == "dev"
|
|
58
58
|
Requires-Dist: mike<3.0.0,>=2.1.3; extra == "dev"
|
|
59
59
|
Requires-Dist: pyright<2.0.0,>=1.1.392; extra == "dev"
|
|
60
60
|
Requires-Dist: pre-commit<5.0.0,>=4.0.1; extra == "dev"
|
|
@@ -217,12 +217,18 @@ logger.info("Logging info.")
|
|
|
217
217
|
|
|
218
218
|
```yml
|
|
219
219
|
logger:
|
|
220
|
-
app_name:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
app_name: my-app
|
|
221
|
+
default:
|
|
222
|
+
level:
|
|
223
|
+
base: TRACE
|
|
224
|
+
handlers:
|
|
225
|
+
default.all.file_handler:
|
|
224
226
|
enabled: true
|
|
225
|
-
|
|
227
|
+
default.err.file_handler:
|
|
228
|
+
enabled: true
|
|
229
|
+
default.all.json_handler:
|
|
230
|
+
enabled: true
|
|
231
|
+
default.err.json_handler:
|
|
226
232
|
enabled: true
|
|
227
233
|
```
|
|
228
234
|
|
|
@@ -273,28 +279,28 @@ python ./main.py
|
|
|
273
279
|
**Output**:
|
|
274
280
|
|
|
275
281
|
```txt
|
|
276
|
-
[
|
|
277
|
-
[
|
|
278
|
-
[
|
|
279
|
-
[
|
|
280
|
-
[
|
|
281
|
-
[
|
|
282
|
-
[
|
|
283
|
-
[
|
|
284
|
-
[
|
|
285
|
-
[
|
|
282
|
+
[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: [];
|
|
283
|
+
[2025-11-01 00:00:00.736 +09:00 | TRACE | __main__:6]: Tracing...
|
|
284
|
+
[2025-11-01 00:00:00.736 +09:00 | DEBUG | __main__:7]: Debugging...
|
|
285
|
+
[2025-11-01 00:00:00.736 +09:00 | INFO | __main__:8]: Logging info.
|
|
286
|
+
[2025-11-01 00:00:00.736 +09:00 | OK | __main__:9]: Success.
|
|
287
|
+
[2025-11-01 00:00:00.736 +09:00 | WARN | __main__:10]: Warning something.
|
|
288
|
+
[2025-11-01 00:00:00.736 +09:00 | ERROR | __main__:11]: Error occured.
|
|
289
|
+
[2025-11-01 00:00:00.736 +09:00 | CRIT | __main__:12]: CRITICAL ERROR.
|
|
290
|
+
[2025-11-01 00:00:00.736 +09:00 | ERROR | __main__:24]: division by zero
|
|
291
|
+
[2025-11-01 00:00:00.737 +09:00 | ERROR | __main__:31]: Show me, what value is wrong:
|
|
286
292
|
Traceback (most recent call last):
|
|
287
293
|
|
|
288
|
-
> File "/home/user/workspaces/projects/
|
|
294
|
+
> File "/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py", line 29, in <module>
|
|
289
295
|
nested(0)
|
|
290
|
-
└ <function nested at
|
|
296
|
+
└ <function nested at 0x102f37910>
|
|
291
297
|
|
|
292
|
-
File "/home/user/workspaces/projects/
|
|
298
|
+
File "/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py", line 22, in nested
|
|
293
299
|
divide(5, c)
|
|
294
300
|
│ └ 0
|
|
295
|
-
└ <function divide at
|
|
301
|
+
└ <function divide at 0x102f377f0>
|
|
296
302
|
|
|
297
|
-
File "/home/user/workspaces/projects/
|
|
303
|
+
File "/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py", line 16, in divide
|
|
298
304
|
_result = a / b
|
|
299
305
|
│ └ 0
|
|
300
306
|
└ 5
|
|
@@ -312,37 +318,54 @@ ZeroDivisionError: division by zero
|
|
|
312
318
|
|
|
313
319
|
```yaml
|
|
314
320
|
logger:
|
|
315
|
-
# app_name:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
log_path: "{app_name}.json.all.log"
|
|
338
|
-
err_path: "{app_name}.json.err.log"
|
|
321
|
+
# app_name: app
|
|
322
|
+
default:
|
|
323
|
+
level:
|
|
324
|
+
base: INFO
|
|
325
|
+
err: WARNING
|
|
326
|
+
std:
|
|
327
|
+
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>"
|
|
328
|
+
colorize: true
|
|
329
|
+
format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:<5} | {name}:{line}]: {message}"
|
|
330
|
+
file:
|
|
331
|
+
logs_dir: "./logs"
|
|
332
|
+
rotate_size: 10000000
|
|
333
|
+
rotate_time: "00:00:00"
|
|
334
|
+
retention: 90
|
|
335
|
+
encoding: utf8
|
|
336
|
+
plain:
|
|
337
|
+
log_path: "{app_name}.all.log"
|
|
338
|
+
err_path: "{app_name}.err.log"
|
|
339
|
+
json:
|
|
340
|
+
log_path: "json/{app_name}.json.all.log"
|
|
341
|
+
err_path: "json/{app_name}.json.err.log"
|
|
342
|
+
custom_serialize: false
|
|
339
343
|
intercept:
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
ignore_modules: []
|
|
344
|
+
enabled: true
|
|
345
|
+
only_base: false
|
|
346
|
+
ignore_modules: []
|
|
344
347
|
include_modules: []
|
|
345
348
|
mute_modules: []
|
|
349
|
+
handlers:
|
|
350
|
+
default.all.std_handler:
|
|
351
|
+
type: STD
|
|
352
|
+
enabled: true
|
|
353
|
+
default.all.file_handler:
|
|
354
|
+
type: FILE
|
|
355
|
+
enabled: false
|
|
356
|
+
default.err.file_handler:
|
|
357
|
+
type: FILE
|
|
358
|
+
error: true
|
|
359
|
+
enabled: false
|
|
360
|
+
default.all.json_handler:
|
|
361
|
+
type: FILE
|
|
362
|
+
serialize: true
|
|
363
|
+
enabled: false
|
|
364
|
+
default.err.json_handler:
|
|
365
|
+
type: FILE
|
|
366
|
+
serialize: true
|
|
367
|
+
error: true
|
|
368
|
+
enabled: false
|
|
346
369
|
extra:
|
|
347
370
|
```
|
|
348
371
|
|
|
@@ -354,10 +377,6 @@ logger:
|
|
|
354
377
|
# ENV=LOCAL
|
|
355
378
|
# DEBUG=false
|
|
356
379
|
# TZ=UTC
|
|
357
|
-
|
|
358
|
-
# BEANS_LOGGING_DISABLE_DEFAULT=false
|
|
359
|
-
# BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
|
|
360
|
-
# BEANS_LOGGING_LOGS_DIR="./logs"
|
|
361
380
|
```
|
|
362
381
|
|
|
363
382
|
---
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
beans_logging/__init__.py,sha256=KOXpuCNTMsdlY9MF6ONwRjM5O1_JCkIzt_qetb2BFTw,261
|
|
2
|
+
beans_logging/__version__.py,sha256=VgMOOqsYbyb60I1RmlZpqwqQ0C0IyT3R0c8_xX4pRGM,22
|
|
3
|
+
beans_logging/_builder.py,sha256=KUHZLMj6AqyDQGpVVB4XGEP3xI_kkjNMG-pbV_PvtLE,5644
|
|
4
|
+
beans_logging/_constants.py,sha256=rH9ZN-b7GXNXjbpOZUJfsft54Eiy8jnXm82jsFcMo3k,510
|
|
5
|
+
beans_logging/_core.py,sha256=qkGl5NRKY7lKuVatwFmddwxeYS5viU5DDnfKucWK3Mo,9617
|
|
6
|
+
beans_logging/_intercept.py,sha256=TeYze0eXRMVkOoC9Bl2qmaC7fSwExfQAmmGHz5KiuCU,3249
|
|
7
|
+
beans_logging/auto.py,sha256=MoNuQomiIFWQVpNTkOmFFVMo00HBlErfHC728GFOyqc,218
|
|
8
|
+
beans_logging/config.py,sha256=yDA-IbjhMIgP1DrFKa0ZDibNWAH_Ov8R7Hnqfggl71E,6172
|
|
9
|
+
beans_logging/filters.py,sha256=-Rys2rwuT7EUvuEA19jnhW6enIEkDuPzeGbAAz6RJSc,3720
|
|
10
|
+
beans_logging/formats.py,sha256=Vrr4RkCfiJl-oi6BLVxeR-k0WhTR0oBI4mpsWgBJBNE,1624
|
|
11
|
+
beans_logging/rotators.py,sha256=lzR31sdEPTZVDkyhC81FL4OnezIVKlElGJDRA2Svn2I,2121
|
|
12
|
+
beans_logging/schemas.py,sha256=b4igq8CkAzn7CGOBDc09hW0YTvWyuWRe97fpv_OaNdk,4444
|
|
13
|
+
beans_logging/sinks.py,sha256=7Guusg3N1S-28hLnRzuunP8lXnhexzny3aj-AR0HhuQ,482
|
|
14
|
+
beans_logging-7.0.0.dist-info/licenses/LICENSE.txt,sha256=CUTK-r0BWIg1r0bBiemAcMhakgV0N7HuRhw6rQ-A9A4,1074
|
|
15
|
+
beans_logging-7.0.0.dist-info/METADATA,sha256=v6LwlP4Gc4ZnyvYnVHka9okW38UV9e2f2A_23-5Q9qs,13155
|
|
16
|
+
beans_logging-7.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
beans_logging-7.0.0.dist-info/top_level.txt,sha256=lx8JEqYGNha1sYbVrTtMo2Z01A7Shq8hX6bfsuKLTG8,14
|
|
18
|
+
beans_logging-7.0.0.dist-info/RECORD,,
|