custom-python-logger 0.1.0__tar.gz → 0.1.2__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-0.1.0/custom_python_logger.egg-info → custom_python_logger-0.1.2}/PKG-INFO +30 -2
  2. custom_python_logger-0.1.2/README.md +38 -0
  3. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger/logger.py +7 -11
  4. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2/custom_python_logger.egg-info}/PKG-INFO +30 -2
  5. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/setup.py +4 -1
  6. custom_python_logger-0.1.0/README.md +0 -12
  7. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/LICENSE +0 -0
  8. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/MANIFEST.in +0 -0
  9. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger/__init__.py +0 -0
  10. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger/usage_example.py +0 -0
  11. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger.egg-info/SOURCES.txt +0 -0
  12. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger.egg-info/dependency_links.txt +0 -0
  13. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger.egg-info/requires.txt +0 -0
  14. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/custom_python_logger.egg-info/top_level.txt +0 -0
  15. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/pyproject.toml +0 -0
  16. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/setup.cfg +0 -0
  17. {custom_python_logger-0.1.0 → custom_python_logger-0.1.2}/tests/test_logger.py +0 -0
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
7
7
  Author-email:
8
+ Project-URL: Repository, https://github.com/aviz92/custom-python-logger
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: Programming Language :: Python :: 3.7
10
11
  Classifier: License :: OSI Approved :: MIT License
@@ -24,6 +25,7 @@ Dynamic: description
24
25
  Dynamic: description-content-type
25
26
  Dynamic: home-page
26
27
  Dynamic: license-file
28
+ Dynamic: project-url
27
29
  Dynamic: requires-dist
28
30
  Dynamic: requires-python
29
31
  Dynamic: summary
@@ -39,4 +41,30 @@ pip install custom-python-logger
39
41
  ```
40
42
 
41
43
  ## Usage
42
- please see the [usage_example](custom_python_logger/usage_example.py) file for more details.
44
+ ```python
45
+ import logging
46
+ from custom_python_logger.logger import get_logger
47
+
48
+ def main():
49
+ logger = get_logger(
50
+ project_name='Logger Project Test',
51
+ log_level=logging.DEBUG,
52
+ extra={'user': 'test_user'}
53
+ )
54
+
55
+ logger.debug("This is a debug message.")
56
+ logger.info("This is an info message.")
57
+ logger.step("This is a step message.")
58
+ logger.warning("This is a warning message.")
59
+
60
+ try:
61
+ _ = 1 / 0
62
+ except ZeroDivisionError:
63
+ logger.exception("This is an exception message.")
64
+
65
+ logger.critical("This is a critical message.")
66
+
67
+
68
+ if __name__ == '__main__':
69
+ main()
70
+ ```
@@ -0,0 +1,38 @@
1
+ # Custom Logger
2
+ A Python logger with colored output and additional log levels. <br>
3
+ The logger supports custom log levels like `STEP` and `EXCEPTION` and can be easily integrated into your Python projects.
4
+
5
+ ## Installation
6
+ You can install the package using pip:
7
+ ```bash
8
+ pip install custom-python-logger
9
+ ```
10
+
11
+ ## Usage
12
+ ```python
13
+ import logging
14
+ from custom_python_logger.logger import get_logger
15
+
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
+
23
+ logger.debug("This is a debug message.")
24
+ logger.info("This is an info message.")
25
+ logger.step("This is a step message.")
26
+ logger.warning("This is a warning message.")
27
+
28
+ try:
29
+ _ = 1 / 0
30
+ except ZeroDivisionError:
31
+ logger.exception("This is an exception message.")
32
+
33
+ logger.critical("This is a critical message.")
34
+
35
+
36
+ if __name__ == '__main__':
37
+ main()
38
+ ```
@@ -9,17 +9,10 @@ from typing import Optional, Any
9
9
  from colorlog import ColoredFormatter
10
10
 
11
11
 
12
- def get_project_path(project_name: str) -> str:
13
- current_path = Path(__file__).parent
14
- while current_path != current_path.parent:
15
- if str(current_path).endswith(f'/{project_name}'):
16
- return str(current_path)
17
- current_path = current_path.parent
18
- raise FileNotFoundError(
19
- f'Project "{project_name}" not found in any parent directories.\n'
20
- f'Current path: {Path(__file__)}',
21
- )
22
-
12
+ def get_root_project_path() -> Path:
13
+ if 'venv' in str(Path(__file__)):
14
+ return Path(__file__).parents[5]
15
+ return Path(__file__).parent
23
16
 
24
17
  def print_before_logger(project_name: str) -> None:
25
18
  main_string = f'Start "{project_name}" Process'
@@ -133,6 +126,9 @@ def get_logger(
133
126
  """
134
127
  print_before_logger(project_name=project_name)
135
128
 
129
+ if not log_file:
130
+ log_file = f'{get_root_project_path()}/logs/{project_name}.log'
131
+
136
132
  configure_logging(
137
133
  log_level=logging.DEBUG,
138
134
  log_format=log_format,
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: custom-python-logger
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
7
7
  Author-email:
8
+ Project-URL: Repository, https://github.com/aviz92/custom-python-logger
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: Programming Language :: Python :: 3.7
10
11
  Classifier: License :: OSI Approved :: MIT License
@@ -24,6 +25,7 @@ Dynamic: description
24
25
  Dynamic: description-content-type
25
26
  Dynamic: home-page
26
27
  Dynamic: license-file
28
+ Dynamic: project-url
27
29
  Dynamic: requires-dist
28
30
  Dynamic: requires-python
29
31
  Dynamic: summary
@@ -39,4 +41,30 @@ pip install custom-python-logger
39
41
  ```
40
42
 
41
43
  ## Usage
42
- please see the [usage_example](custom_python_logger/usage_example.py) file for more details.
44
+ ```python
45
+ import logging
46
+ from custom_python_logger.logger import get_logger
47
+
48
+ def main():
49
+ logger = get_logger(
50
+ project_name='Logger Project Test',
51
+ log_level=logging.DEBUG,
52
+ extra={'user': 'test_user'}
53
+ )
54
+
55
+ logger.debug("This is a debug message.")
56
+ logger.info("This is an info message.")
57
+ logger.step("This is a step message.")
58
+ logger.warning("This is a warning message.")
59
+
60
+ try:
61
+ _ = 1 / 0
62
+ except ZeroDivisionError:
63
+ logger.exception("This is an exception message.")
64
+
65
+ logger.critical("This is a critical message.")
66
+
67
+
68
+ if __name__ == '__main__':
69
+ main()
70
+ ```
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='custom-python-logger',
5
- version='0.1.0',
5
+ version='0.1.2',
6
6
  packages=find_packages(include=['custom_python_logger', 'custom_python_logger.*']),
7
7
  install_requires=[
8
8
  'colorlog>=4.0.0',
@@ -18,6 +18,9 @@ setup(
18
18
  long_description=open('README.md').read(),
19
19
  long_description_content_type='text/markdown',
20
20
  url='https://github.com/aviz92/custom-python-logger',
21
+ project_urls={
22
+ 'Repository': 'https://github.com/aviz92/custom-python-logger',
23
+ },
21
24
  classifiers=[
22
25
  'Programming Language :: Python :: 3',
23
26
  'Programming Language :: Python :: 3.7',
@@ -1,12 +0,0 @@
1
- # Custom Logger
2
- A Python logger with colored output and additional log levels. <br>
3
- The logger supports custom log levels like `STEP` and `EXCEPTION` and can be easily integrated into your Python projects.
4
-
5
- ## Installation
6
- You can install the package using pip:
7
- ```bash
8
- pip install custom-python-logger
9
- ```
10
-
11
- ## Usage
12
- please see the [usage_example](custom_python_logger/usage_example.py) file for more details.