custom-python-logger 1.0.8__tar.gz → 1.0.10__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-1.0.8/custom_python_logger.egg-info → custom_python_logger-1.0.10}/PKG-INFO +11 -8
  2. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/README.md +10 -7
  3. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger/logger.py +15 -10
  4. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10/custom_python_logger.egg-info}/PKG-INFO +11 -8
  5. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/setup.py +1 -1
  6. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/LICENSE +0 -0
  7. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/MANIFEST.in +0 -0
  8. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger/__init__.py +0 -0
  9. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger/usage_example.py +0 -0
  10. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/SOURCES.txt +0 -0
  11. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/dependency_links.txt +0 -0
  12. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/requires.txt +0 -0
  13. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/top_level.txt +0 -0
  14. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/pyproject.toml +0 -0
  15. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/requirements.txt +0 -0
  16. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/setup.cfg +0 -0
  17. {custom_python_logger-1.0.8 → custom_python_logger-1.0.10}/tests/test_logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 1.0.8
3
+ Version: 1.0.10
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
@@ -38,15 +38,12 @@ pip install custom-python-logger
38
38
  ## Usage
39
39
  ```python
40
40
  import logging
41
- from custom_python_logger.logger import get_logger
41
+ from custom_python_logger.logger import get_logger, CustomLoggerAdapter
42
+
43
+ logger: CustomLoggerAdapter = CustomLoggerAdapter(logging.getLogger(__name__))
42
44
 
43
- def main():
44
- logger = get_logger(
45
- project_name='Logger Project Test',
46
- log_level=logging.DEBUG,
47
- extra={'user': 'test_user'}
48
- )
49
45
 
46
+ def main():
50
47
  logger.debug("This is a debug message.")
51
48
  logger.info("This is an info message.")
52
49
  logger.step("This is a step message.")
@@ -61,6 +58,12 @@ def main():
61
58
 
62
59
 
63
60
  if __name__ == '__main__':
61
+ _ = get_logger(
62
+ project_name='Logger Project Test',
63
+ log_level=logging.DEBUG,
64
+ extra={'user': 'test_user'}
65
+ )
66
+
64
67
  main()
65
68
  ```
66
69
 
@@ -11,15 +11,12 @@ pip install custom-python-logger
11
11
  ## Usage
12
12
  ```python
13
13
  import logging
14
- from custom_python_logger.logger import get_logger
14
+ from custom_python_logger.logger import get_logger, CustomLoggerAdapter
15
+
16
+ logger: CustomLoggerAdapter = CustomLoggerAdapter(logging.getLogger(__name__))
15
17
 
16
- def main():
17
- logger = get_logger(
18
- project_name='Logger Project Test',
19
- log_level=logging.DEBUG,
20
- extra={'user': 'test_user'}
21
- )
22
18
 
19
+ def main():
23
20
  logger.debug("This is a debug message.")
24
21
  logger.info("This is an info message.")
25
22
  logger.step("This is a step message.")
@@ -34,6 +31,12 @@ def main():
34
31
 
35
32
 
36
33
  if __name__ == '__main__':
34
+ _ = get_logger(
35
+ project_name='Logger Project Test',
36
+ log_level=logging.DEBUG,
37
+ extra={'user': 'test_user'}
38
+ )
39
+
37
40
  main()
38
41
  ```
39
42
 
@@ -44,7 +44,8 @@ def configure_logging(
44
44
  log_format: str,
45
45
  utc: bool,
46
46
  log_level: int = logging.INFO,
47
- log_file: Optional[str] = None,
47
+ log_file: bool = False,
48
+ log_file_path: Optional[str] = None,
48
49
  console_output: bool = True,
49
50
  ) -> None:
50
51
  """
@@ -53,7 +54,8 @@ def configure_logging(
53
54
  Args:
54
55
  log_level: Logging level (default: INFO)
55
56
  log_format: Format string for log messages
56
- log_file: Path to log file (if None, no file logging)
57
+ log_file: Whether to log to a file
58
+ log_file_path: Path to log file (if None, no file logging)
57
59
  console_output: Whether to output logs to console
58
60
  utc: Whether to use UTC time for log timestamps
59
61
  """
@@ -68,15 +70,15 @@ def configure_logging(
68
70
  root_logger.removeHandler(handler)
69
71
 
70
72
  # Add file handler if specified
71
- if log_file is not None:
73
+ if log_file and log_file_path is not None:
72
74
  log_file_formatter = logging.Formatter(log_format)
73
75
 
74
76
  # Create directory if it doesn't exist
75
- log_dir = os.path.dirname(log_file)
77
+ log_dir = os.path.dirname(log_file_path)
76
78
  if log_dir and not os.path.exists(log_dir):
77
79
  os.makedirs(log_dir)
78
80
 
79
- file_handler = logging.FileHandler(log_file)
81
+ file_handler = logging.FileHandler(log_file_path)
80
82
 
81
83
  file_handler.setFormatter(log_file_formatter)
82
84
  root_logger.addHandler(file_handler)
@@ -107,7 +109,8 @@ def get_logger(
107
109
  extra: Optional[dict[str, Any]] = None,
108
110
  log_format: str = "%(asctime)s | %(levelname)-10s(l.%(levelno)s) | %(filename)s:%(lineno)s | %(message)s",
109
111
  log_level: int = logging.INFO,
110
- log_file: str = None,
112
+ log_file: bool = False,
113
+ log_file_path: str = None,
111
114
  console_output: bool = True,
112
115
  utc: bool = False,
113
116
  ) -> CustomLoggerAdapter[Logger | LoggerAdapter[Any] | Any] | Logger:
@@ -119,7 +122,8 @@ def get_logger(
119
122
  log_level: Optional specific log level
120
123
  extra: Optional dictionary of extra context values
121
124
  log_format: Format string for log messages
122
- log_file: Path to log file (if None, no file logging)
125
+ log_file: Whether to log to a file
126
+ log_file_path: Path to log file (if None, no file logging)
123
127
  console_output: Whether to output logs to console
124
128
  utc: Whether to use UTC time for log timestamps
125
129
 
@@ -128,14 +132,15 @@ def get_logger(
128
132
  """
129
133
  print_before_logger(project_name=project_name)
130
134
 
131
- if not log_file:
132
- log_file = f'{get_root_project_path()}/logs/{project_name}.log'
133
- log_file = log_file.lower().replace(' ', '_')
135
+ if not log_file_path:
136
+ log_file_path = f'{get_root_project_path()}/logs/{project_name}.log'
137
+ log_file_path = log_file_path.lower().replace(' ', '_')
134
138
 
135
139
  configure_logging(
136
140
  log_level=logging.DEBUG,
137
141
  log_format=log_format,
138
142
  log_file=log_file,
143
+ log_file_path=log_file_path,
139
144
  console_output=console_output,
140
145
  utc=utc
141
146
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 1.0.8
3
+ Version: 1.0.10
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
@@ -38,15 +38,12 @@ pip install custom-python-logger
38
38
  ## Usage
39
39
  ```python
40
40
  import logging
41
- from custom_python_logger.logger import get_logger
41
+ from custom_python_logger.logger import get_logger, CustomLoggerAdapter
42
+
43
+ logger: CustomLoggerAdapter = CustomLoggerAdapter(logging.getLogger(__name__))
42
44
 
43
- def main():
44
- logger = get_logger(
45
- project_name='Logger Project Test',
46
- log_level=logging.DEBUG,
47
- extra={'user': 'test_user'}
48
- )
49
45
 
46
+ def main():
50
47
  logger.debug("This is a debug message.")
51
48
  logger.info("This is an info message.")
52
49
  logger.step("This is a step message.")
@@ -61,6 +58,12 @@ def main():
61
58
 
62
59
 
63
60
  if __name__ == '__main__':
61
+ _ = get_logger(
62
+ project_name='Logger Project Test',
63
+ log_level=logging.DEBUG,
64
+ extra={'user': 'test_user'}
65
+ )
66
+
64
67
  main()
65
68
  ```
66
69
 
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- package_version = '1.0.8'
3
+ package_version = '1.0.10'
4
4
 
5
5
  package_name = 'custom-python-logger'
6
6
  package_description = 'A custom logger with color support and additional features.'