overhead-log 1.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.
overhead_log/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from argparse import Action, ArgumentParser
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
from enum import IntEnum
|
|
5
|
+
from typing import Any, Self
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
import loguru # type: ignore # noqa: F401
|
|
9
|
+
|
|
10
|
+
LOGURU_INSTALLED: bool = True
|
|
11
|
+
except ImportError:
|
|
12
|
+
LOGURU_INSTALLED: bool = False
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
from pydantic import Field # type: ignore
|
|
16
|
+
except ImportError:
|
|
17
|
+
Field = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Level(IntEnum):
|
|
21
|
+
CRITICAL = logging.CRITICAL = 50
|
|
22
|
+
ERROR = logging.ERROR = 40
|
|
23
|
+
WARNING = logging.WARNING = 30
|
|
24
|
+
INFO = logging.INFO = 20
|
|
25
|
+
DEBUG = logging.DEBUG = 10
|
|
26
|
+
ALL = logging.NOTSET = 0
|
|
27
|
+
|
|
28
|
+
if LOGURU_INSTALLED:
|
|
29
|
+
TRACE = 5
|
|
30
|
+
|
|
31
|
+
FATAL = CRITICAL
|
|
32
|
+
WARN = WARNING
|
|
33
|
+
DEFAULT = INFO
|
|
34
|
+
|
|
35
|
+
def __init__(self, *_):
|
|
36
|
+
if self.name not in self._value2member_map_:
|
|
37
|
+
self._value2member_map_[self.name] = self
|
|
38
|
+
if self.name.lower() not in self._value2member_map_:
|
|
39
|
+
self._value2member_map_[self.name.lower()] = self
|
|
40
|
+
if str(self.value) not in self._value2member_map_:
|
|
41
|
+
self._value2member_map_[str(self.value)] = self
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def add_argument(
|
|
45
|
+
cls,
|
|
46
|
+
parser: ArgumentParser,
|
|
47
|
+
flags: Iterable[str] = ("-ll", "--log-level"),
|
|
48
|
+
default: Any = DEFAULT,
|
|
49
|
+
help: str | None = "",
|
|
50
|
+
**kwargs,
|
|
51
|
+
) -> Action:
|
|
52
|
+
return parser.add_argument(
|
|
53
|
+
*flags,
|
|
54
|
+
default=default,
|
|
55
|
+
help=help,
|
|
56
|
+
**kwargs,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def field(cls, *args, **kwargs) -> Self:
|
|
61
|
+
if Field is None:
|
|
62
|
+
raise ImportError("Install pydantic to use this method.")
|
|
63
|
+
return Field(*args, **kwargs)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: overhead-log
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Keywords: logging,level,utility,convenience
|
|
5
|
+
Classifier: Development Status :: 1 - Planning
|
|
6
|
+
Classifier: Operating System :: OS Independent
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Topic :: Utilities
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Provides-Extra: extra
|
|
12
|
+
Requires-Dist: loguru; extra == "extra"
|
|
13
|
+
Requires-Dist: pydantic; extra == "extra"
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
overhead_log/__init__.py,sha256=VSa1wbJHCMKybBWpWmVfC96UwlPEsfmgSxwymUzd2so,1656
|
|
2
|
+
overhead_log-1.0.0.dist-info/METADATA,sha256=bOtDJN8utFKgkQUBnFfbp4jEnjlR1fCrf76FHmISLko,445
|
|
3
|
+
overhead_log-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
4
|
+
overhead_log-1.0.0.dist-info/top_level.txt,sha256=wuVaNum-ZhnCpw80gzEHdvgZBGoIyY30JV6Mye0qjOA,13
|
|
5
|
+
overhead_log-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
overhead_log
|