custom-python-logger 1.0.9__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.9/custom_python_logger.egg-info → custom_python_logger-1.0.10}/PKG-INFO +1 -1
  2. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger/logger.py +15 -10
  3. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10/custom_python_logger.egg-info}/PKG-INFO +1 -1
  4. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/setup.py +1 -1
  5. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/LICENSE +0 -0
  6. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/MANIFEST.in +0 -0
  7. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/README.md +0 -0
  8. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger/__init__.py +0 -0
  9. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger/usage_example.py +0 -0
  10. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/SOURCES.txt +0 -0
  11. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/dependency_links.txt +0 -0
  12. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/requires.txt +0 -0
  13. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/custom_python_logger.egg-info/top_level.txt +0 -0
  14. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/pyproject.toml +0 -0
  15. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/requirements.txt +0 -0
  16. {custom_python_logger-1.0.9 → custom_python_logger-1.0.10}/setup.cfg +0 -0
  17. {custom_python_logger-1.0.9 → 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.9
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
@@ -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.9
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
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- package_version = '1.0.9'
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.'