julien-python-toolkit 0.1.8__tar.gz → 0.1.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: julien-python-toolkit
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Important code that I reuse through multiple projects. Please see license for allowed use.
5
5
  Home-page: https://github.com/JulienPython/JulienPythonToolkit-V001
6
6
  Author: Julien Python
@@ -69,11 +69,30 @@ class Logger():
69
69
  def set_stream_log_level(self, log_level):
70
70
 
71
71
  for handler in self._logger.handlers:
72
- if isinstance(handler, logging.StreamHandler) and stream_log_level is not None:
73
- handler.setLevel(stream_log_level)
72
+ if isinstance(handler, logging.StreamHandler) and log_level is not None:
73
+ handler.setLevel(log_level)
74
74
 
75
75
  def set_file_log_level(self, log_level):
76
76
 
77
77
  for handler in self._logger.handlers:
78
- if isinstance(handler, logging.RotatingFileHandler) and stream_log_level is not None:
79
- handler.setLevel(stream_log_level)
78
+ if isinstance(handler, logging.handlers.RotatingFileHandler) and log_level is not None:
79
+ handler.setLevel(log_level)
80
+
81
+
82
+ if __name__ == '__main__':
83
+
84
+ # Step 1: Set stream log level high (WARN) and file log level low (DEBUG)
85
+ # We should see only WARN message on stream but both WARN and DEBUG messages in file
86
+
87
+ logger = Logger("Test", "test.log", stream_log_level = WARNING, file_log_level = DEBUG)
88
+
89
+ logger.warn("This should be in steam & file.")
90
+ logger.debug("This should be in file only.")
91
+
92
+ # Step 2: Set stream log level low (INFO) and file log level high (ERROR)
93
+
94
+ logger.set_stream_log_level(INFO)
95
+ logger.set_file_log_level(ERROR)
96
+
97
+ logger.info("This should be in stream only.")
98
+ logger.error("This should be in steam & file.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: julien-python-toolkit
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Important code that I reuse through multiple projects. Please see license for allowed use.
5
5
  Home-page: https://github.com/JulienPython/JulienPythonToolkit-V001
6
6
  Author: Julien Python
@@ -11,7 +11,7 @@ with open('requirements.txt') as f:
11
11
 
12
12
  setup(
13
13
  name='julien-python-toolkit',
14
- version='0.1.8',
14
+ version='0.1.9',
15
15
  packages=find_packages(),
16
16
  license='Custom Non-Commercial License', # Reference your custom license
17
17
  install_requires=required, # Use the list from requirements.txt