dvlogger 0.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.
dvlogger-0.2/PKG-INFO ADDED
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: dvlogger
3
+ Version: 0.2
4
+ Summary: A custom logger with coloured output and uncaught exception logging.
5
+ Home-page: https://github.com/mlpranav/dvlogger
6
+ Author: Pranav Mittal
7
+ Author-email: pranavmittal611@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: colorama
dvlogger-0.2/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # dvlogger
2
+
3
+ - Instead of `import logging`, do `from dvlogger import logging` for coloured and formatted logging output.
4
+ - Also enables automatic logging of uncaught exceptions by overriding `sys.excepthook`.
@@ -0,0 +1,3 @@
1
+ from .logconfig import setup, logging
2
+
3
+ console_handler = setup()
@@ -0,0 +1,47 @@
1
+ import logging, sys, traceback
2
+ import colorama
3
+
4
+ def handle_exception(exc_type, exc_value, exc_traceback):
5
+ if issubclass(exc_type, KeyboardInterrupt):
6
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
7
+ return
8
+ logging.error(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
9
+
10
+ class CustomFormatter(logging.Formatter):
11
+ def __init__(self, fmt, datefmt):
12
+ super().__init__(fmt=fmt, datefmt=datefmt)
13
+ grey = "\033[90m"
14
+ white = "\033[97m"
15
+ yellow = "\033[33m"
16
+ red = "\033[31m"
17
+ bold_red = "\033[1;31m"
18
+ reset = "\033[0m"
19
+
20
+ self.FORMATS = {
21
+ logging.DEBUG: grey + self._fmt + reset,
22
+ logging.INFO: white + self._fmt + reset,
23
+ logging.WARNING: yellow + self._fmt + reset,
24
+ logging.ERROR: red + self._fmt + reset,
25
+ logging.CRITICAL: bold_red + self._fmt + reset
26
+ }
27
+
28
+ def format(self, record):
29
+ log_fmt = self.FORMATS.get(record.levelno)
30
+ formatter = logging.Formatter(log_fmt)
31
+ return formatter.format(record)
32
+
33
+ def setup():
34
+ colorama.init()
35
+ sys.excepthook = handle_exception
36
+ formatter_string = '%(asctime)s.%(msecs)03d - %(threadName)s - %(levelname)s - %(module)s - %(funcName)s - %(message)s'
37
+ formatter_string_date = '%Y-%m-%d %H:%M:%S'
38
+ logging.captureWarnings(True)
39
+ logger = logging.getLogger()
40
+ logger.setLevel(logging.DEBUG)
41
+ formatter = CustomFormatter(fmt=formatter_string, datefmt=formatter_string_date)
42
+ console_handler = logging.StreamHandler(sys.stdout)
43
+ console_handler.setLevel(logging.DEBUG)
44
+ console_handler.setFormatter(formatter)
45
+ logger.handlers = [console_handler]
46
+ logging.info('*******')
47
+ return console_handler
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: dvlogger
3
+ Version: 0.2
4
+ Summary: A custom logger with coloured output and uncaught exception logging.
5
+ Home-page: https://github.com/mlpranav/dvlogger
6
+ Author: Pranav Mittal
7
+ Author-email: pranavmittal611@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: colorama
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ dvlogger/__init__.py
4
+ dvlogger/logconfig.py
5
+ dvlogger.egg-info/PKG-INFO
6
+ dvlogger.egg-info/SOURCES.txt
7
+ dvlogger.egg-info/dependency_links.txt
8
+ dvlogger.egg-info/requires.txt
9
+ dvlogger.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ colorama
@@ -0,0 +1 @@
1
+ dvlogger
dvlogger-0.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
dvlogger-0.2/setup.py ADDED
@@ -0,0 +1,17 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='dvlogger',
5
+ version='0.2',
6
+ description='A custom logger with coloured output and uncaught exception logging.',
7
+ packages=find_packages(),
8
+ install_requires=['colorama'],
9
+ author='Pranav Mittal',
10
+ author_email='pranavmittal611@gmail.com',
11
+ url='https://github.com/mlpranav/dvlogger',
12
+ classifiers=[
13
+ 'Programming Language :: Python :: 3',
14
+ 'Operating System :: OS Independent',
15
+ ],
16
+ python_requires='>=3.8',
17
+ )