beans-logging 6.0.3__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 +17 -5
- beans_logging/_core.py +295 -0
- beans_logging/_intercept.py +106 -0
- beans_logging/auto.py +3 -12
- beans_logging/config.py +118 -70
- beans_logging/filters.py +37 -20
- beans_logging/formats.py +20 -4
- beans_logging/{rotation.py → rotators.py} +20 -14
- beans_logging/schemas.py +143 -0
- beans_logging/sinks.py +11 -2
- {beans_logging-6.0.3.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 -642
- beans_logging/_handlers.py +0 -40
- beans_logging/_utils.py +0 -101
- beans_logging-6.0.3.dist-info/RECORD +0 -17
- {beans_logging-6.0.3.dist-info → beans_logging-7.0.0.dist-info}/WHEEL +0 -0
- {beans_logging-6.0.3.dist-info → beans_logging-7.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {beans_logging-6.0.3.dist-info → beans_logging-7.0.0.dist-info}/top_level.txt +0 -0
beans_logging/_utils.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
import copy
|
|
4
|
-
import errno
|
|
5
|
-
|
|
6
|
-
from loguru import logger
|
|
7
|
-
from pydantic import validate_call
|
|
8
|
-
|
|
9
|
-
from ._constants import WarnEnum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@validate_call
|
|
13
|
-
def create_dir(create_dir: str, warn_mode: WarnEnum = WarnEnum.DEBUG):
|
|
14
|
-
"""Create directory if `create_dir` doesn't exist.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
create_dir (str, required): Create directory path.
|
|
18
|
-
warn_mode (str, optional): Warning message mode, for example: 'ERROR', 'ALWAYS', 'DEBUG', 'IGNORE'.
|
|
19
|
-
Defaults to "DEBUG".
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
if not os.path.isdir(create_dir):
|
|
23
|
-
try:
|
|
24
|
-
_message = f"Creaing '{create_dir}' directory..."
|
|
25
|
-
if warn_mode == WarnEnum.ALWAYS:
|
|
26
|
-
logger.info(_message)
|
|
27
|
-
elif warn_mode == WarnEnum.DEBUG:
|
|
28
|
-
logger.debug(_message)
|
|
29
|
-
|
|
30
|
-
os.makedirs(create_dir)
|
|
31
|
-
except OSError as err:
|
|
32
|
-
if err.errno == errno.EEXIST:
|
|
33
|
-
logger.debug(f"'{create_dir}' directory already exists!")
|
|
34
|
-
else:
|
|
35
|
-
logger.error(f"Failed to create '{create_dir}' directory!")
|
|
36
|
-
raise
|
|
37
|
-
|
|
38
|
-
_message = f"Successfully created '{create_dir}' directory."
|
|
39
|
-
if warn_mode == WarnEnum.ALWAYS:
|
|
40
|
-
logger.success(_message)
|
|
41
|
-
elif warn_mode == WarnEnum.DEBUG:
|
|
42
|
-
logger.debug(_message)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@validate_call
|
|
46
|
-
def deep_merge(dict1: dict, dict2: dict) -> dict:
|
|
47
|
-
"""Return a new dictionary that's the result of a deep merge of two dictionaries.
|
|
48
|
-
If there are conflicts, values from `dict2` will overwrite those in `dict1`.
|
|
49
|
-
|
|
50
|
-
Args:
|
|
51
|
-
dict1 (dict, required): The base dictionary that will be merged.
|
|
52
|
-
dict2 (dict, required): The dictionary to merge into `dict1`.
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
dict: The merged dictionary.
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
_merged = copy.deepcopy(dict1)
|
|
59
|
-
for _key, _val in dict2.items():
|
|
60
|
-
if (
|
|
61
|
-
_key in _merged
|
|
62
|
-
and isinstance(_merged[_key], dict)
|
|
63
|
-
and isinstance(_val, dict)
|
|
64
|
-
):
|
|
65
|
-
_merged[_key] = deep_merge(_merged[_key], _val)
|
|
66
|
-
else:
|
|
67
|
-
_merged[_key] = copy.deepcopy(_val)
|
|
68
|
-
|
|
69
|
-
return _merged
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@validate_call
|
|
73
|
-
def get_slug_name(file_path: str | None = None) -> str:
|
|
74
|
-
"""Slugify the file name from the given file path or the current script's file path.
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
file_path (str | None, optional): The file path to slugify. If None, uses the current script's file path.
|
|
78
|
-
Defaults to None.
|
|
79
|
-
|
|
80
|
-
Returns:
|
|
81
|
-
str: The slugified file name.
|
|
82
|
-
"""
|
|
83
|
-
|
|
84
|
-
if not file_path:
|
|
85
|
-
file_path = sys.argv[0]
|
|
86
|
-
|
|
87
|
-
_slug_name = (
|
|
88
|
-
os.path.splitext(os.path.basename(file_path))[0]
|
|
89
|
-
.strip()
|
|
90
|
-
.replace(" ", "-")
|
|
91
|
-
.replace("_", "-")
|
|
92
|
-
.lower()
|
|
93
|
-
)
|
|
94
|
-
return _slug_name
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
__all__ = [
|
|
98
|
-
"create_dir",
|
|
99
|
-
"deep_merge",
|
|
100
|
-
"get_slug_name",
|
|
101
|
-
]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
beans_logging/__init__.py,sha256=lBMzr_ft3ogvyPllFg58g8ykQqw3nPeFlOSCLkPAJJ8,274
|
|
2
|
-
beans_logging/__version__.py,sha256=IN3BPhf5H6oc5xFMBUqLJxc7gEfbTvO94mfwBiqqzvQ,22
|
|
3
|
-
beans_logging/_base.py,sha256=C2-58LELhnyGW_kOZlQQLu_B32apRWDfqxMmybzCH1E,23921
|
|
4
|
-
beans_logging/_constants.py,sha256=OqSvH2IvsUSbvIgthHeiv92i9CHXKYvO-PCb_DsMANI,320
|
|
5
|
-
beans_logging/_handlers.py,sha256=cz2jcJR0MuVHWWNRAFT617njC_18Q56lNcgKIxLmFys,1106
|
|
6
|
-
beans_logging/_utils.py,sha256=R4laUGfe81WsJmkMbZ6hcw8P_du9TSOMR5aX-tHmsUo,2871
|
|
7
|
-
beans_logging/auto.py,sha256=YQMfmWK6mFEwqabhimj8ZA_yStKZCDQEvteKv2UIbEA,494
|
|
8
|
-
beans_logging/config.py,sha256=EpxTUYXaLRfLv9IAHlGTbggr3rN21ElOst0JGil4D6c,4384
|
|
9
|
-
beans_logging/filters.py,sha256=iikVBMIhAF_DP1F0X0GJ7GUOvP-JdcH_CxAsYuz0UxM,3343
|
|
10
|
-
beans_logging/formats.py,sha256=WTIDP0uJL9J9bcFZ2_Qe8zlw_l4SrE2k2agPLvrjfMM,1324
|
|
11
|
-
beans_logging/rotation.py,sha256=t-ORXq7x4tDbvz8XMjCCuDZ6cUApcu3SBQzfgTwHQU8,2110
|
|
12
|
-
beans_logging/sinks.py,sha256=t2U4v95H_tV2ci6YS8aKCnTUKVRxEcsLnB55qn4wyrQ,331
|
|
13
|
-
beans_logging-6.0.3.dist-info/licenses/LICENSE.txt,sha256=CUTK-r0BWIg1r0bBiemAcMhakgV0N7HuRhw6rQ-A9A4,1074
|
|
14
|
-
beans_logging-6.0.3.dist-info/METADATA,sha256=5jfV5gzxMrMiVpkVfnAPZ1YWTEBk8-552JeTJZsmckU,12652
|
|
15
|
-
beans_logging-6.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
-
beans_logging-6.0.3.dist-info/top_level.txt,sha256=lx8JEqYGNha1sYbVrTtMo2Z01A7Shq8hX6bfsuKLTG8,14
|
|
17
|
-
beans_logging-6.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|