custom-python-logger 2.0.6__tar.gz → 2.0.7__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.
Files changed (19) hide show
  1. {custom_python_logger-2.0.6/custom_python_logger.egg-info → custom_python_logger-2.0.7}/PKG-INFO +1 -1
  2. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/consts.py +7 -0
  3. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/logger.py +21 -5
  4. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7/custom_python_logger.egg-info}/PKG-INFO +1 -1
  5. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/setup.py +1 -1
  6. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/LICENSE +0 -0
  7. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/MANIFEST.in +0 -0
  8. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/README.md +0 -0
  9. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/__init__.py +0 -0
  10. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/SOURCES.txt +0 -0
  11. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/dependency_links.txt +0 -0
  12. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/requires.txt +0 -0
  13. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/top_level.txt +0 -0
  14. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/pyproject.toml +0 -0
  15. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/requirements.txt +0 -0
  16. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/setup.cfg +0 -0
  17. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_logger.py +0 -0
  18. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_logger_pytest.py +0 -0
  19. {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_usage_example_pytest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: A custom logger with color support and additional features.
5
5
  Home-page: https://github.com/aviz92/custom-python-logger
6
6
  Author: Avi Zaguri
@@ -8,9 +8,16 @@ LOG_COLORS = {
8
8
  "ERROR": "red,bold",
9
9
  "EXCEPTION": "light_red,bold",
10
10
  "CRITICAL": "red,bg_white",
11
+ "SUCCESS": "bold_green",
12
+ "FATAL": "red,bg_white",
13
+ "ALERT": "bold_yellow",
14
+ "TRACE": "bold_cyan",
11
15
  }
12
16
 
13
17
 
14
18
  class CustomLoggerLevel(Enum):
15
19
  EXCEPTION = 45
16
20
  STEP = 25
21
+ SUCCESS = 26
22
+ ALERT = 35
23
+ TRACE = 15
@@ -12,7 +12,7 @@ from colorlog import ColoredFormatter
12
12
 
13
13
  from custom_python_logger.consts import LOG_COLORS, CustomLoggerLevel
14
14
 
15
- CHILD_LOGGER = "child_logger"
15
+ CUSTOM_LOGGER = "custom_logger"
16
16
 
17
17
 
18
18
  def json_pretty_format(data: Any, indent: int = 4, sort_keys: bool = True, default: Callable = None) -> str:
@@ -60,6 +60,21 @@ class CustomLoggerAdapter(logging.LoggerAdapter):
60
60
  kwargs.setdefault("stacklevel", 2)
61
61
  self.log(CustomLoggerLevel.STEP.value, msg, *args, exc_info=False, **kwargs)
62
62
 
63
+ def success(self, msg: str, *args, **kwargs) -> None:
64
+ logging.addLevelName(CustomLoggerLevel.SUCCESS.value, "SUCCESS")
65
+ kwargs.setdefault("stacklevel", 2)
66
+ self.log(CustomLoggerLevel.SUCCESS.value, msg, *args, **kwargs)
67
+
68
+ def alert(self, msg: str, *args, **kwargs) -> None:
69
+ logging.addLevelName(CustomLoggerLevel.ALERT.value, "ALERT")
70
+ kwargs.setdefault("stacklevel", 2)
71
+ self.log(CustomLoggerLevel.ALERT.value, msg, *args, **kwargs)
72
+
73
+ def trace(self, msg: str, *args, **kwargs) -> None:
74
+ logging.addLevelName(CustomLoggerLevel.TRACE.value, "TRACE")
75
+ kwargs.setdefault("stacklevel", 2)
76
+ self.log(CustomLoggerLevel.TRACE.value, msg, *args, **kwargs)
77
+
63
78
 
64
79
  def clear_existing_handlers(logger: Logger) -> None:
65
80
  for handler in logger.handlers[:]:
@@ -137,11 +152,12 @@ def configure_logging(
137
152
 
138
153
 
139
154
  def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
140
- child_logger = logging.getLogger(CHILD_LOGGER)
141
- new_logger = CustomLoggerAdapter(logging.getLogger(name), extra=extra)
155
+ custom_logger = logging.getLogger(CUSTOM_LOGGER)
156
+ full_name = f"{CUSTOM_LOGGER}.{name}"
157
+ new_logger = CustomLoggerAdapter(logging.getLogger(full_name), extra=extra)
142
158
 
143
159
  if not log_level:
144
- log_level = child_logger.level
160
+ log_level = custom_logger.level
145
161
  new_logger.setLevel(log_level)
146
162
 
147
163
  return new_logger
@@ -183,7 +199,7 @@ def build_logger(
183
199
  console_output=console_output,
184
200
  utc=utc,
185
201
  )
186
- logger = CustomLoggerAdapter(logging.getLogger(CHILD_LOGGER), extra)
202
+ logger = CustomLoggerAdapter(logging.getLogger(CUSTOM_LOGGER), extra)
187
203
  logger.setLevel(log_level)
188
204
 
189
205
  return get_logger(project_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: A custom logger with color support and additional features.
5
5
  Home-page: https://github.com/aviz92/custom-python-logger
6
6
  Author: Avi Zaguri
@@ -1,6 +1,6 @@
1
1
  from setuptools import find_packages, setup
2
2
 
3
- package_version = "2.0.6"
3
+ package_version = "2.0.7"
4
4
 
5
5
  package_name = "custom-python-logger"
6
6
  package_description = "A custom logger with color support and additional features."