From 48a3e5e88fd6f5917ea7bd54892a777d7361baef Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Tue, 11 Oct 2022 05:25:17 +0200 Subject: [PATCH] The logger is still not multiprocess capable! This needs to be fixed. I added comments with more information. --- bin/linspector | 2 +- etc/linspector.conf | 2 +- linspector/core/logger.py | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/linspector b/bin/linspector index ad8c726..ecf0a10 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.56.dev1' +__version__ = '0.19.57.dev1' __author__ = 'Johannes Findeisen ' diff --git a/etc/linspector.conf b/etc/linspector.conf index 7f120fb..d2e9925 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -7,7 +7,7 @@ log_level= debug log_file = ~/code/linspector/linspector/log/linspector.log ; number of log files to be kept. i recommend to use the lowest sensible value for keeping performance high. so set ; the size of the log file higher to increase the log history. -log_file_count = 10 +log_file_count = 20 ; log file size in megabytes as int. the default is 10000000 bytes (10MiB) set in the code if not configured here. log_file_size = 1 ; log file size in bytes as int. you can set to bytes if you want to set a value lower then 1 megabyte. but it will diff --git a/linspector/core/logger.py b/linspector/core/logger.py index 29951ac..f3d3043 100644 --- a/linspector/core/logger.py +++ b/linspector/core/logger.py @@ -13,6 +13,11 @@ from logging import handlers logger = getLogger('linspector') +# wow, this is not process capable! i thought in a last commit that the problem ist fixed, but it +# isn't!!! see here for more details: +# https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes +# a different approach on handling this can be to use a exclusive log file for each process but +# this is not what i want. # maybe subclass it from logging.Logger...? class Log: def __init__(self, configuration, stdout, verbose): @@ -102,6 +107,7 @@ class Log: import inspect import multiprocessing import threading + # https://www.geeksforgeeks.org/how-to-get-the-process-id-from-python-multiprocess/ current_process = multiprocessing.current_process() from_stack = inspect.stack()[1] function_name = from_stack.function