#1679 logger.py: Fix logging to log the intended MBS.<category>
Opened 3 years ago by otaylor. Modified a year ago
otaylor/fm-orchestrator log-category  into  master

@@ -482,7 +482,7 @@ 

      def __init__(self):

          self._logger = logging.getLogger("MBS")

          self._level = logging.NOTSET

-         self._current_path = os.path.dirname(os.path.realpath(__file__))

+         self._current_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

  

      @property

      def logger(self):

@@ -13,6 +13,7 @@ 

  import textwrap

  from unittest.mock import patch

  

+ from module_build_service.builder.utils import execute_cmd

  from module_build_service.common import log, models

  from module_build_service.common.logger import ModuleBuildLogs, MBSConsoleHandler

  from module_build_service.scheduler.consumer import MBSConsumer
@@ -92,6 +93,9 @@ 

          log.error("ignore this test msg2")

          self.build_log.current_log_stream.write("ignore this test output2")

  

+         # Get a message logged by a different part of MBS

+         execute_cmd(["true"])

+ 

          self.build_log.stop(build)

          assert os.path.exists(path)

          with open(path, "r") as f:
@@ -101,6 +105,9 @@ 

                  assert data.find("MBS - {0} - ignore this test msg2".format(level)) != -1

              assert data.find("ignore this test output2")

  

+             # Check that we log the category correctly

+             assert data.find("MBS.builder.utils - INFO - Executing the command") != -1

+ 

          # Try to log more messages when build_log for module 1 is stopped.

          # New messages should not appear in a log.

          MBSConsumer.current_module_build_id = 2

The move of logger.py to common/logger.py
(https://pagure.io/fm-orchestrator/c/c7c650a4f0) broke the log
formatting introduced in https://pagure.io/fm-orchestrator/pull-request/1161,
so all logging outside the common directory was logged as 'MBS' instead
of 'MBS.<category>'

Build e4fa6836dca0d3b91b131a739ea04d3b4fb808b5 FAILED!
Rebase or make new commits to rebuild.

Note: while this is an obvious fix that should help reading the logs, it's not on my critical path - I tracked it down and worked around it, because the old version of 'flatpak-module build-module' that parses and cleans up MBS logs broke when Fedora was updated to MBS 3.4.

rebased onto a21734c9339ce4488fa6d055909faa4ffaed1beb

2 years ago

rebased onto 6e8ee1d

a year ago

rebased onto 8c4ef3d

a year ago