beans-logging 6.0.1__tar.gz → 6.0.2__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-6.0.1/src/beans_logging.egg-info → beans_logging-6.0.2}/PKG-INFO +13 -8
- {beans_logging-6.0.1 → beans_logging-6.0.2}/README.md +11 -6
- {beans_logging-6.0.1 → beans_logging-6.0.2}/pyproject.toml +1 -1
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/__init__.py +0 -2
- beans_logging-6.0.2/src/beans_logging/__version__.py +1 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/_base.py +35 -39
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/_consts.py +0 -2
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/_handlers.py +2 -4
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/_utils.py +2 -3
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/auto.py +2 -3
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/filters.py +0 -3
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/formats.py +0 -2
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/rotation.py +2 -4
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/schemas.py +7 -7
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging/sinks.py +0 -2
- {beans_logging-6.0.1 → beans_logging-6.0.2/src/beans_logging.egg-info}/PKG-INFO +13 -8
- beans_logging-6.0.1/src/beans_logging/__version__.py +0 -1
- {beans_logging-6.0.1 → beans_logging-6.0.2}/.python-version +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/LICENSE.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/auto.py +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements/requirements.build.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements/requirements.dev.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements/requirements.docs.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements/requirements.fastapi.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements/requirements.test.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/requirements.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/setup.cfg +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/setup.py +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging.egg-info/SOURCES.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging.egg-info/dependency_links.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging.egg-info/requires.txt +0 -0
- {beans_logging-6.0.1 → beans_logging-6.0.2}/src/beans_logging.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beans_logging
|
|
3
|
-
Version: 6.0.
|
|
4
|
-
Summary: 'beans-logging' is a python package for simple logger and easily managing
|
|
3
|
+
Version: 6.0.2
|
|
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
|
|
7
7
|
Project-URL: Documentation, https://pylogging-docs.bybatkhuu.dev
|
|
@@ -100,7 +100,7 @@ It is a `Loguru` based custom logging package for python projects.
|
|
|
100
100
|
[OPTIONAL] For **DEVELOPMENT** environment:
|
|
101
101
|
|
|
102
102
|
- Install [**git**](https://git-scm.com/downloads)
|
|
103
|
-
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
103
|
+
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
104
104
|
|
|
105
105
|
### 2. 📥 Download or clone the repository
|
|
106
106
|
|
|
@@ -213,7 +213,7 @@ logger.info("Logging info.")
|
|
|
213
213
|
|
|
214
214
|
### **Simple**
|
|
215
215
|
|
|
216
|
-
[**`configs/logger.yml`**](
|
|
216
|
+
[**`configs/logger.yml`**](./examples/simple/configs/logger.yml):
|
|
217
217
|
|
|
218
218
|
```yml
|
|
219
219
|
logger:
|
|
@@ -226,9 +226,11 @@ logger:
|
|
|
226
226
|
enabled: true
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
[**`main.py`**](
|
|
229
|
+
[**`main.py`**](./examples/simple/main.py):
|
|
230
230
|
|
|
231
231
|
```python
|
|
232
|
+
#!/usr/bin/env python
|
|
233
|
+
|
|
232
234
|
from beans_logging.auto import logger
|
|
233
235
|
|
|
234
236
|
|
|
@@ -240,10 +242,12 @@ logger.warning("Warning something.")
|
|
|
240
242
|
logger.error("Error occured.")
|
|
241
243
|
logger.critical("CRITICAL ERROR.")
|
|
242
244
|
|
|
245
|
+
|
|
243
246
|
def divide(a, b):
|
|
244
247
|
_result = a / b
|
|
245
248
|
return _result
|
|
246
249
|
|
|
250
|
+
|
|
247
251
|
def nested(c):
|
|
248
252
|
try:
|
|
249
253
|
divide(5, c)
|
|
@@ -251,13 +255,14 @@ def nested(c):
|
|
|
251
255
|
logger.error(err)
|
|
252
256
|
raise
|
|
253
257
|
|
|
258
|
+
|
|
254
259
|
try:
|
|
255
260
|
nested(0)
|
|
256
|
-
except Exception
|
|
261
|
+
except Exception:
|
|
257
262
|
logger.exception("Show me, what value is wrong:")
|
|
258
263
|
```
|
|
259
264
|
|
|
260
|
-
Run the [**`examples/simple`**](
|
|
265
|
+
Run the [**`examples/simple`**](./examples/simple):
|
|
261
266
|
|
|
262
267
|
```sh
|
|
263
268
|
cd ./examples/simple
|
|
@@ -303,7 +308,7 @@ ZeroDivisionError: division by zero
|
|
|
303
308
|
|
|
304
309
|
## ⚙️ Configuration
|
|
305
310
|
|
|
306
|
-
[**`templates/configs/
|
|
311
|
+
[**`templates/configs/logger.yml`**](./templates/configs/logger.yml):
|
|
307
312
|
|
|
308
313
|
```yaml
|
|
309
314
|
logger:
|
|
@@ -38,7 +38,7 @@ It is a `Loguru` based custom logging package for python projects.
|
|
|
38
38
|
[OPTIONAL] For **DEVELOPMENT** environment:
|
|
39
39
|
|
|
40
40
|
- Install [**git**](https://git-scm.com/downloads)
|
|
41
|
-
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
41
|
+
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
42
42
|
|
|
43
43
|
### 2. 📥 Download or clone the repository
|
|
44
44
|
|
|
@@ -151,7 +151,7 @@ logger.info("Logging info.")
|
|
|
151
151
|
|
|
152
152
|
### **Simple**
|
|
153
153
|
|
|
154
|
-
[**`configs/logger.yml`**](
|
|
154
|
+
[**`configs/logger.yml`**](./examples/simple/configs/logger.yml):
|
|
155
155
|
|
|
156
156
|
```yml
|
|
157
157
|
logger:
|
|
@@ -164,9 +164,11 @@ logger:
|
|
|
164
164
|
enabled: true
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
[**`main.py`**](
|
|
167
|
+
[**`main.py`**](./examples/simple/main.py):
|
|
168
168
|
|
|
169
169
|
```python
|
|
170
|
+
#!/usr/bin/env python
|
|
171
|
+
|
|
170
172
|
from beans_logging.auto import logger
|
|
171
173
|
|
|
172
174
|
|
|
@@ -178,10 +180,12 @@ logger.warning("Warning something.")
|
|
|
178
180
|
logger.error("Error occured.")
|
|
179
181
|
logger.critical("CRITICAL ERROR.")
|
|
180
182
|
|
|
183
|
+
|
|
181
184
|
def divide(a, b):
|
|
182
185
|
_result = a / b
|
|
183
186
|
return _result
|
|
184
187
|
|
|
188
|
+
|
|
185
189
|
def nested(c):
|
|
186
190
|
try:
|
|
187
191
|
divide(5, c)
|
|
@@ -189,13 +193,14 @@ def nested(c):
|
|
|
189
193
|
logger.error(err)
|
|
190
194
|
raise
|
|
191
195
|
|
|
196
|
+
|
|
192
197
|
try:
|
|
193
198
|
nested(0)
|
|
194
|
-
except Exception
|
|
199
|
+
except Exception:
|
|
195
200
|
logger.exception("Show me, what value is wrong:")
|
|
196
201
|
```
|
|
197
202
|
|
|
198
|
-
Run the [**`examples/simple`**](
|
|
203
|
+
Run the [**`examples/simple`**](./examples/simple):
|
|
199
204
|
|
|
200
205
|
```sh
|
|
201
206
|
cd ./examples/simple
|
|
@@ -241,7 +246,7 @@ ZeroDivisionError: division by zero
|
|
|
241
246
|
|
|
242
247
|
## ⚙️ Configuration
|
|
243
248
|
|
|
244
|
-
[**`templates/configs/
|
|
249
|
+
[**`templates/configs/logger.yml`**](./templates/configs/logger.yml):
|
|
245
250
|
|
|
246
251
|
```yaml
|
|
247
252
|
logger:
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "beans_logging"
|
|
7
7
|
authors = [{ name = "Batkhuu Byambajav", email = "batkhuu10@gmail.com" }]
|
|
8
|
-
description = "'beans-logging' is a python package for simple logger and easily managing
|
|
8
|
+
description = "'beans-logging' is a python package for simple logger and easily managing logs."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10,<4.0"
|
|
11
11
|
keywords = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "6.0.2"
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Standard libraries
|
|
1
|
+
# Standard libraries
|
|
4
2
|
import os
|
|
5
3
|
import copy
|
|
6
4
|
import json
|
|
7
5
|
import logging
|
|
8
|
-
from typing import
|
|
6
|
+
from typing import Any
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
# Third-party libraries
|
|
11
9
|
import yaml
|
|
12
10
|
from loguru import logger
|
|
13
11
|
from loguru._logger import Logger
|
|
@@ -18,7 +16,7 @@ if "2.0.0" <= pydantic.__version__:
|
|
|
18
16
|
else:
|
|
19
17
|
from pydantic import validate_arguments as validate_call
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
# Internal modules
|
|
22
20
|
from ._utils import create_dir, deep_merge
|
|
23
21
|
from ._handlers import InterceptHandler
|
|
24
22
|
from .rotation import RotationChecker
|
|
@@ -67,7 +65,7 @@ class LoggerLoader:
|
|
|
67
65
|
@validate_call
|
|
68
66
|
def __init__(
|
|
69
67
|
self,
|
|
70
|
-
config:
|
|
68
|
+
config: LoggerConfigPM | dict[str, Any] | None = None,
|
|
71
69
|
config_file_path: str = _CONFIG_FILE_PATH,
|
|
72
70
|
auto_config_file: bool = True,
|
|
73
71
|
auto_load: bool = False,
|
|
@@ -75,12 +73,14 @@ class LoggerLoader:
|
|
|
75
73
|
"""LoggerLoader constructor method.
|
|
76
74
|
|
|
77
75
|
Args:
|
|
78
|
-
config (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
auto_config_file (bool
|
|
83
|
-
|
|
76
|
+
config (LoggerConfigPM | dict | None], optional): New logger config to update loaded config.
|
|
77
|
+
Defaults to None.
|
|
78
|
+
config_file_path (str , optional): Logger config file path. Defaults to
|
|
79
|
+
`LoggerLoader._CONFIG_FILE_PATH`.
|
|
80
|
+
auto_config_file (bool , optional): Indicates whether to load logger config
|
|
81
|
+
file or not. Defaults to True.
|
|
82
|
+
auto_load (bool , optional): Indicates whether to load logger
|
|
83
|
+
handlers or not. Defaults to False.
|
|
84
84
|
"""
|
|
85
85
|
|
|
86
86
|
self.handlers_map = {"default": 0}
|
|
@@ -125,9 +125,7 @@ class LoggerLoader:
|
|
|
125
125
|
return logger
|
|
126
126
|
|
|
127
127
|
@validate_call
|
|
128
|
-
def remove_handler(
|
|
129
|
-
self, handler: Union[str, None] = None, handler_type: str = "NAME"
|
|
130
|
-
):
|
|
128
|
+
def remove_handler(self, handler: str | None = None, handler_type: str = "NAME"):
|
|
131
129
|
"""Remove all handlers or specific handler by name or id from logger.
|
|
132
130
|
|
|
133
131
|
Raises:
|
|
@@ -162,7 +160,7 @@ class LoggerLoader:
|
|
|
162
160
|
self.handlers_map.clear()
|
|
163
161
|
|
|
164
162
|
@validate_call
|
|
165
|
-
def update_config(self, config:
|
|
163
|
+
def update_config(self, config: LoggerConfigPM | dict[str, Any]):
|
|
166
164
|
"""Update logger config with new config.
|
|
167
165
|
|
|
168
166
|
Args:
|
|
@@ -213,13 +211,11 @@ class LoggerLoader:
|
|
|
213
211
|
# elif self.config_file_path.lower().endswith(".toml"):
|
|
214
212
|
# _file_format = "TOML"
|
|
215
213
|
|
|
216
|
-
|
|
214
|
+
# Loading config from file, if it's exits:
|
|
217
215
|
if os.path.isfile(self.config_file_path):
|
|
218
216
|
if _file_format == "YAML":
|
|
219
217
|
try:
|
|
220
|
-
with open(
|
|
221
|
-
self.config_file_path, "r", encoding="utf-8"
|
|
222
|
-
) as _config_file:
|
|
218
|
+
with open(self.config_file_path, encoding="utf-8") as _config_file:
|
|
223
219
|
_new_config_dict = yaml.safe_load(_config_file) or {}
|
|
224
220
|
if "logger" not in _new_config_dict:
|
|
225
221
|
logger.warning(
|
|
@@ -242,9 +238,7 @@ class LoggerLoader:
|
|
|
242
238
|
raise
|
|
243
239
|
elif _file_format == "JSON":
|
|
244
240
|
try:
|
|
245
|
-
with open(
|
|
246
|
-
self.config_file_path, "r", encoding="utf-8"
|
|
247
|
-
) as _config_file:
|
|
241
|
+
with open(self.config_file_path, encoding="utf-8") as _config_file:
|
|
248
242
|
_new_config_dict = json.load(_config_file) or {}
|
|
249
243
|
if "logger" not in _new_config_dict:
|
|
250
244
|
logger.warning(
|
|
@@ -296,7 +290,7 @@ class LoggerLoader:
|
|
|
296
290
|
def _check_env(self):
|
|
297
291
|
"""Check environment variables for logger config."""
|
|
298
292
|
|
|
299
|
-
|
|
293
|
+
# Checking environment for DEBUG option:
|
|
300
294
|
_is_debug = False
|
|
301
295
|
_ENV = str(os.getenv("ENV")).strip().lower()
|
|
302
296
|
_DEBUG = str(os.getenv("DEBUG")).strip().lower()
|
|
@@ -314,7 +308,7 @@ class LoggerLoader:
|
|
|
314
308
|
self.config.file.logs_dir = os.getenv("BEANS_LOGGING_LOGS_DIR")
|
|
315
309
|
|
|
316
310
|
# if self.config.stream.use_color:
|
|
317
|
-
#
|
|
311
|
+
# # Checking terminal could support xterm colors:
|
|
318
312
|
# _TERM = str(os.getenv("TERM")).strip()
|
|
319
313
|
# if not "xterm" in _TERM:
|
|
320
314
|
# self.config.stream.use_color = False
|
|
@@ -536,7 +530,7 @@ class LoggerLoader:
|
|
|
536
530
|
|
|
537
531
|
_intercept_handler = InterceptHandler()
|
|
538
532
|
|
|
539
|
-
|
|
533
|
+
# Intercepting all logs from standard (root logger) logging:
|
|
540
534
|
logging.basicConfig(handlers=[_intercept_handler], level=0, force=True)
|
|
541
535
|
|
|
542
536
|
_intercepted_modules = set()
|
|
@@ -579,10 +573,10 @@ class LoggerLoader:
|
|
|
579
573
|
f"Intercepted modules: {list(_intercepted_modules)}; Muted modules: {list(_muted_modules)};"
|
|
580
574
|
)
|
|
581
575
|
|
|
582
|
-
|
|
583
|
-
|
|
576
|
+
# ATTRIBUTES #
|
|
577
|
+
# handlers_map
|
|
584
578
|
@property
|
|
585
|
-
def handlers_map(self) ->
|
|
579
|
+
def handlers_map(self) -> dict[str, int]:
|
|
586
580
|
try:
|
|
587
581
|
return self.__handlers_map
|
|
588
582
|
except AttributeError:
|
|
@@ -591,7 +585,7 @@ class LoggerLoader:
|
|
|
591
585
|
return self.__handlers_map
|
|
592
586
|
|
|
593
587
|
@handlers_map.setter
|
|
594
|
-
def handlers_map(self, handlers_map:
|
|
588
|
+
def handlers_map(self, handlers_map: dict[str, int]):
|
|
595
589
|
if not isinstance(handlers_map, dict):
|
|
596
590
|
raise TypeError(
|
|
597
591
|
f"`handlers_map` attribute type {type(handlers_map)} is invalid, must be <dict>!."
|
|
@@ -599,9 +593,9 @@ class LoggerLoader:
|
|
|
599
593
|
|
|
600
594
|
self.__handlers_map = copy.deepcopy(handlers_map)
|
|
601
595
|
|
|
602
|
-
|
|
596
|
+
# handlers_map
|
|
603
597
|
|
|
604
|
-
|
|
598
|
+
# config
|
|
605
599
|
@property
|
|
606
600
|
def config(self) -> LoggerConfigPM:
|
|
607
601
|
try:
|
|
@@ -620,9 +614,9 @@ class LoggerLoader:
|
|
|
620
614
|
|
|
621
615
|
self.__config = copy.deepcopy(config)
|
|
622
616
|
|
|
623
|
-
|
|
617
|
+
# config
|
|
624
618
|
|
|
625
|
-
|
|
619
|
+
# config_file_path
|
|
626
620
|
@property
|
|
627
621
|
def config_file_path(self) -> str:
|
|
628
622
|
try:
|
|
@@ -648,11 +642,13 @@ class LoggerLoader:
|
|
|
648
642
|
):
|
|
649
643
|
if not config_file_path.lower().endswith(".toml"):
|
|
650
644
|
raise NotImplementedError(
|
|
651
|
-
f"`config_file_path` attribute value '{config_file_path}' is invalid,
|
|
645
|
+
f"`config_file_path` attribute value '{config_file_path}' is invalid, "
|
|
646
|
+
f"TOML file format is not supported yet!"
|
|
652
647
|
)
|
|
653
648
|
|
|
654
649
|
raise ValueError(
|
|
655
|
-
f"`config_file_path` attribute value '{config_file_path}' is invalid,
|
|
650
|
+
f"`config_file_path` attribute value '{config_file_path}' is invalid, "
|
|
651
|
+
f"file must be '.yml', '.yaml' or '.json' format!"
|
|
656
652
|
)
|
|
657
653
|
|
|
658
654
|
if not os.path.isabs(config_file_path):
|
|
@@ -660,5 +656,5 @@ class LoggerLoader:
|
|
|
660
656
|
|
|
661
657
|
self.__config_file_path = config_file_path
|
|
662
658
|
|
|
663
|
-
|
|
664
|
-
|
|
659
|
+
# config_file_path
|
|
660
|
+
# ATTRIBUTES #
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
import sys
|
|
4
2
|
import logging
|
|
5
3
|
from logging import LogRecord
|
|
@@ -25,13 +23,13 @@ class InterceptHandler(logging.Handler):
|
|
|
25
23
|
record (LogRecord, required): Log needs to be handled.
|
|
26
24
|
"""
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
# Get corresponding Loguru level if it exists
|
|
29
27
|
try:
|
|
30
28
|
_level = logger.level(record.levelname).name
|
|
31
29
|
except ValueError:
|
|
32
30
|
_level = record.levelno
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
# Find caller from where originated the logged message
|
|
35
33
|
_frame, _depth = sys._getframe(6), 6
|
|
36
34
|
while _frame and _frame.f_code.co_filename == logging.__file__:
|
|
37
35
|
_frame = _frame.f_back
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
import os
|
|
4
2
|
import sys
|
|
5
3
|
import copy
|
|
@@ -22,7 +20,8 @@ def create_dir(create_dir: str, warn_mode: WarnEnum = WarnEnum.DEBUG):
|
|
|
22
20
|
|
|
23
21
|
Args:
|
|
24
22
|
create_dir (str, required): Create directory path.
|
|
25
|
-
warn_mode (str, optional): Warning message mode, for example: 'ERROR', 'ALWAYS', 'DEBUG', 'IGNORE'.
|
|
23
|
+
warn_mode (str, optional): Warning message mode, for example: 'ERROR', 'ALWAYS', 'DEBUG', 'IGNORE'.
|
|
24
|
+
Defaults to "DEBUG".
|
|
26
25
|
"""
|
|
27
26
|
|
|
28
27
|
if not os.path.isdir(create_dir):
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# flake8: noqa
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
from typing import Union
|
|
5
4
|
|
|
6
5
|
from . import *
|
|
7
6
|
|
|
8
|
-
logger_loader:
|
|
7
|
+
logger_loader: LoggerLoader | None = None
|
|
9
8
|
_DISABLE_DEFAULT_LOGGER = (
|
|
10
9
|
str(os.getenv("BEANS_LOGGING_DISABLE_DEFAULT")).strip().lower()
|
|
11
10
|
)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
import datetime
|
|
4
2
|
from typing import TextIO
|
|
5
3
|
|
|
@@ -35,8 +33,8 @@ class RotationChecker:
|
|
|
35
33
|
)
|
|
36
34
|
|
|
37
35
|
if _current_dtime >= self._dtime_limit:
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
# The current time is already past the target time so it would rotate already.
|
|
37
|
+
# Add one day to prevent an immediate rotation.
|
|
40
38
|
self._dtime_limit += datetime.timedelta(days=1)
|
|
41
39
|
|
|
42
40
|
def should_rotate(self, message: Message, file: TextIO) -> bool:
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
import datetime
|
|
4
|
-
from typing import List
|
|
5
2
|
|
|
6
3
|
|
|
7
4
|
import pydantic
|
|
@@ -34,7 +31,10 @@ class StreamPM(ExtraBaseModel):
|
|
|
34
31
|
use_color: bool = Field(default=True)
|
|
35
32
|
use_icon: bool = Field(default=False)
|
|
36
33
|
format_str: constr(strip_whitespace=True) = Field(
|
|
37
|
-
default=
|
|
34
|
+
default=(
|
|
35
|
+
"[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{level_short:<5}</level> | <w>{name}:{line}</w>]: "
|
|
36
|
+
"<level>{message}</level>"
|
|
37
|
+
),
|
|
38
38
|
min_length=3,
|
|
39
39
|
max_length=511,
|
|
40
40
|
)
|
|
@@ -145,13 +145,13 @@ class FilePM(ExtraBaseModel):
|
|
|
145
145
|
class AutoLoadPM(ExtraBaseModel):
|
|
146
146
|
enabled: bool = Field(default=True)
|
|
147
147
|
only_base: bool = Field(default=False)
|
|
148
|
-
ignore_modules:
|
|
148
|
+
ignore_modules: list[str] = Field(default=[])
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
class InterceptPM(ExtraBaseModel):
|
|
152
152
|
auto_load: AutoLoadPM = Field(default_factory=AutoLoadPM)
|
|
153
|
-
include_modules:
|
|
154
|
-
mute_modules:
|
|
153
|
+
include_modules: list[str] = Field(default=[])
|
|
154
|
+
mute_modules: list[str] = Field(default=[])
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
class ExtraPM(ExtraBaseModel):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beans_logging
|
|
3
|
-
Version: 6.0.
|
|
4
|
-
Summary: 'beans-logging' is a python package for simple logger and easily managing
|
|
3
|
+
Version: 6.0.2
|
|
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
|
|
7
7
|
Project-URL: Documentation, https://pylogging-docs.bybatkhuu.dev
|
|
@@ -100,7 +100,7 @@ It is a `Loguru` based custom logging package for python projects.
|
|
|
100
100
|
[OPTIONAL] For **DEVELOPMENT** environment:
|
|
101
101
|
|
|
102
102
|
- Install [**git**](https://git-scm.com/downloads)
|
|
103
|
-
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
103
|
+
- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
|
|
104
104
|
|
|
105
105
|
### 2. 📥 Download or clone the repository
|
|
106
106
|
|
|
@@ -213,7 +213,7 @@ logger.info("Logging info.")
|
|
|
213
213
|
|
|
214
214
|
### **Simple**
|
|
215
215
|
|
|
216
|
-
[**`configs/logger.yml`**](
|
|
216
|
+
[**`configs/logger.yml`**](./examples/simple/configs/logger.yml):
|
|
217
217
|
|
|
218
218
|
```yml
|
|
219
219
|
logger:
|
|
@@ -226,9 +226,11 @@ logger:
|
|
|
226
226
|
enabled: true
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
[**`main.py`**](
|
|
229
|
+
[**`main.py`**](./examples/simple/main.py):
|
|
230
230
|
|
|
231
231
|
```python
|
|
232
|
+
#!/usr/bin/env python
|
|
233
|
+
|
|
232
234
|
from beans_logging.auto import logger
|
|
233
235
|
|
|
234
236
|
|
|
@@ -240,10 +242,12 @@ logger.warning("Warning something.")
|
|
|
240
242
|
logger.error("Error occured.")
|
|
241
243
|
logger.critical("CRITICAL ERROR.")
|
|
242
244
|
|
|
245
|
+
|
|
243
246
|
def divide(a, b):
|
|
244
247
|
_result = a / b
|
|
245
248
|
return _result
|
|
246
249
|
|
|
250
|
+
|
|
247
251
|
def nested(c):
|
|
248
252
|
try:
|
|
249
253
|
divide(5, c)
|
|
@@ -251,13 +255,14 @@ def nested(c):
|
|
|
251
255
|
logger.error(err)
|
|
252
256
|
raise
|
|
253
257
|
|
|
258
|
+
|
|
254
259
|
try:
|
|
255
260
|
nested(0)
|
|
256
|
-
except Exception
|
|
261
|
+
except Exception:
|
|
257
262
|
logger.exception("Show me, what value is wrong:")
|
|
258
263
|
```
|
|
259
264
|
|
|
260
|
-
Run the [**`examples/simple`**](
|
|
265
|
+
Run the [**`examples/simple`**](./examples/simple):
|
|
261
266
|
|
|
262
267
|
```sh
|
|
263
268
|
cd ./examples/simple
|
|
@@ -303,7 +308,7 @@ ZeroDivisionError: division by zero
|
|
|
303
308
|
|
|
304
309
|
## ⚙️ Configuration
|
|
305
310
|
|
|
306
|
-
[**`templates/configs/
|
|
311
|
+
[**`templates/configs/logger.yml`**](./templates/configs/logger.yml):
|
|
307
312
|
|
|
308
313
|
```yaml
|
|
309
314
|
logger:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "6.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|