custom-python-logger 3.0.0__tar.gz → 3.0.1__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 (17) hide show
  1. {custom_python_logger-3.0.0/custom_python_logger.egg-info → custom_python_logger-3.0.1}/PKG-INFO +1 -1
  2. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/logger.py +12 -26
  3. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1/custom_python_logger.egg-info}/PKG-INFO +1 -1
  4. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/pyproject.toml +1 -1
  5. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/LICENSE +0 -0
  6. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/MANIFEST.in +0 -0
  7. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/README.md +0 -0
  8. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/__init__.py +0 -0
  9. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/consts.py +0 -0
  10. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/SOURCES.txt +0 -0
  11. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/dependency_links.txt +0 -0
  12. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/requires.txt +0 -0
  13. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/top_level.txt +0 -0
  14. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/setup.cfg +0 -0
  15. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_logger.py +0 -0
  16. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_logger_pytest.py +0 -0
  17. {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/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: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: A custom logger with color support and additional features.
5
5
  Author: Avi Zaguri
6
6
  License: MIT
@@ -80,11 +80,7 @@ def clear_existing_handlers(logger: Logger) -> None:
80
80
  logger.removeHandler(handler)
81
81
 
82
82
 
83
- def add_file_handler_if_specified(
84
- logger: Logger,
85
- log_file_path: str | None,
86
- log_format: str,
87
- ) -> None:
83
+ def add_file_handler(logger: Logger, log_file_path: str | None, log_format: str) -> None:
88
84
  if log_file_path is not None:
89
85
  log_file_formatter = logging.Formatter(log_format)
90
86
 
@@ -96,16 +92,15 @@ def add_file_handler_if_specified(
96
92
  logger.addHandler(file_handler)
97
93
 
98
94
 
99
- def add_console_handler_if_specified(logger: Logger, console_output: bool, log_format: str) -> None:
100
- if console_output:
101
- log_console_formatter = ColoredFormatter(
102
- "%(log_color)s " + log_format,
103
- log_colors=LOG_COLORS,
104
- )
95
+ def add_console_handler(logger: Logger, log_format: str) -> None:
96
+ log_console_formatter = ColoredFormatter(
97
+ "%(log_color)s " + log_format,
98
+ log_colors=LOG_COLORS,
99
+ )
105
100
 
106
- console_handler = logging.StreamHandler()
107
- console_handler.setFormatter(log_console_formatter)
108
- logger.addHandler(console_handler)
101
+ console_handler = logging.StreamHandler()
102
+ console_handler.setFormatter(log_console_formatter)
103
+ logger.addHandler(console_handler)
109
104
 
110
105
 
111
106
  def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
@@ -150,25 +145,16 @@ def build_logger( # pylint: disable=R0913
150
145
  logging.Formatter.converter = time.gmtime
151
146
 
152
147
  root_logger = logging.getLogger()
153
-
154
148
  clear_existing_handlers(logger=root_logger)
155
149
 
156
- add_console_handler_if_specified(
157
- logger=root_logger,
158
- console_output=console_output,
159
- log_format=log_format,
160
- )
150
+ if console_output:
151
+ add_console_handler(logger=root_logger, log_format=log_format)
161
152
 
162
153
  if log_file:
163
154
  if not log_file_path:
164
155
  log_file_path = f"{get_project_path_by_file()}/logs/{project_name}.log"
165
156
  log_file_path = log_file_path.lower().replace(" ", "_")
166
-
167
- add_file_handler_if_specified(
168
- logger=root_logger,
169
- log_file_path=log_file_path,
170
- log_format=log_format,
171
- )
157
+ add_file_handler(logger=root_logger, log_file_path=log_file_path, log_format=log_format)
172
158
 
173
159
  logger = CustomLoggerAdapter(logging.getLogger(CUSTOM_LOGGER), extra)
174
160
  logger.setLevel(log_level)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: A custom logger with color support and additional features.
5
5
  Author: Avi Zaguri
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "custom-python-logger"
7
- version = "3.0.0"
7
+ version = "3.0.1"
8
8
  description = "A custom logger with color support and additional features."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"