Added some logging ideas as inline comments.

This commit is contained in:
Johannes Findeisen 2022-10-11 03:34:36 +02:00
commit a2fcec6054
2 changed files with 9 additions and 2 deletions

View file

@ -33,7 +33,7 @@ from linspector.core.monitors import Monitors
# i currently only increase the 3rd number because the goal is that 0.19.* will become the first # i currently only increase the 3rd number because the goal is that 0.19.* will become the first
# stable version. # stable version.
__version__ = '0.19.55.dev1' __version__ = '0.19.56.dev1'
__author__ = 'Johannes Findeisen <you@hanez.org>' __author__ = 'Johannes Findeisen <you@hanez.org>'

View file

@ -13,6 +13,7 @@ from logging import handlers
logger = getLogger('linspector') logger = getLogger('linspector')
# maybe subclass it from logging.Logger...?
class Log: class Log:
def __init__(self, configuration, stdout, verbose): def __init__(self, configuration, stdout, verbose):
self.__configuration = configuration self.__configuration = configuration
@ -27,7 +28,13 @@ class Log:
# initialization of the configuration. maybe there are better solutions...? # initialization of the configuration. maybe there are better solutions...?
self.set_level(logging.INFO) self.set_level(logging.INFO)
stdout_formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s') # some information but not sure if useful in Linspector:
# https://stackoverflow.com/questions/919897/how-to-obtain-a-thread-id-in-python
# %(thread)d : Thread ID (if available).
# %(threadName)s : Thread name (if available).
# this works also for processName
stdout_formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] [%(name)s] '
'%(message)s')
stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(stdout_formatter) stdout_handler.setFormatter(stdout_formatter)
self.add_handler(stdout_handler) self.add_handler(stdout_handler)