[elbe-devel] [PATCH 2/4] elbepack: log: avoid variable name clashes for handlers

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Aug 12 14:24:09 CEST 2024


The variables referencing the handlers shadow the same variables
containing the loggers.
While this is not an issue now, it already is confusing and will be an
actual issue with some future changes.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/log.py | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/elbepack/log.py b/elbepack/log.py
index 19cc22171d02..d296dbfdec88 100644
--- a/elbepack/log.py
+++ b/elbepack/log.py
@@ -113,25 +113,25 @@ def add_stream_handlers(streams):
 def add_project_handlers(projects):
 
     for proj in projects:
-        validation = logging.FileHandler(os.path.join(proj, 'validation.txt'))
-        report = logging.FileHandler(os.path.join(proj, 'elbe-report.txt'))
-        log = logging.FileHandler(os.path.join(proj, 'log.txt'))
-        echo = QHandler(proj)
-        soap = QHandler(proj)
-
-        validation.addFilter(ThreadFilter(['validation']))
-        report.addFilter(ThreadFilter(['report']))
-        log.addFilter(ThreadFilter(['root', 'log', 'report', 'validation']))
-        echo.addFilter(ThreadFilter(['root', 'report', 'validation']))
-        soap.addFilter(ThreadFilter(['soap']))
-
-        validation.setFormatter(msgonly_fmt)
-        report.setFormatter(msgonly_fmt)
-        log.setFormatter(context_fmt)
-        echo.setFormatter(context_fmt)
-        soap.setFormatter(context_fmt)
-
-        yield from [validation, report, log, echo, soap]
+        validation_handler = logging.FileHandler(os.path.join(proj, 'validation.txt'))
+        report_handler = logging.FileHandler(os.path.join(proj, 'elbe-report.txt'))
+        log_handler = logging.FileHandler(os.path.join(proj, 'log.txt'))
+        echo_handler = QHandler(proj)
+        soap_handler = QHandler(proj)
+
+        validation_handler.addFilter(ThreadFilter(['validation']))
+        report_handler.addFilter(ThreadFilter(['report']))
+        log_handler.addFilter(ThreadFilter(['root', 'log', 'report', 'validation']))
+        echo_handler.addFilter(ThreadFilter(['root', 'report', 'validation']))
+        soap_handler.addFilter(ThreadFilter(['soap']))
+
+        validation_handler.setFormatter(msgonly_fmt)
+        report_handler.setFormatter(msgonly_fmt)
+        log_handler.setFormatter(context_fmt)
+        echo_handler.setFormatter(context_fmt)
+        soap_handler.setFormatter(context_fmt)
+
+        yield from [validation_handler, report_handler, log_handler, echo_handler, soap_handler]
 
 
 _logging_methods = {

-- 
2.46.0



More information about the elbe-devel mailing list