From a2fcec605472e108e1b59f025e257bd8cc88f3a1 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Tue, 11 Oct 2022 03:34:36 +0200 Subject: [PATCH] Added some logging ideas as inline comments. --- bin/linspector | 2 +- linspector/core/logger.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/linspector b/bin/linspector index 79f3952..ad8c726 100755 --- a/bin/linspector +++ b/bin/linspector @@ -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 # stable version. -__version__ = '0.19.55.dev1' +__version__ = '0.19.56.dev1' __author__ = 'Johannes Findeisen ' diff --git a/linspector/core/logger.py b/linspector/core/logger.py index 19e75bd..29951ac 100644 --- a/linspector/core/logger.py +++ b/linspector/core/logger.py @@ -13,6 +13,7 @@ from logging import handlers logger = getLogger('linspector') +# maybe subclass it from logging.Logger...? class Log: def __init__(self, configuration, stdout, verbose): self.__configuration = configuration @@ -27,7 +28,13 @@ class Log: # initialization of the configuration. maybe there are better solutions...? 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.setFormatter(stdout_formatter) self.add_handler(stdout_handler)