#1267 Move pkgset skipping logs to separate file
Merged 5 years ago by lsedlar. Opened 5 years ago by hlin.
hlin/pungi master  into  master

file modified
+22
@@ -20,6 +20,7 @@ 

  

  

  import errno

+ import logging

  import os

  import time

  import tempfile
@@ -128,6 +129,27 @@ 

          # Set up logging to file

          if logger:

              kobo.log.add_file_logger(logger, self.paths.log.log_file("global", "pungi.log"))

+             kobo.log.add_file_logger(logger, self.paths.log.log_file("global", "excluding-arch.log"))

+ 

+             class PungiLogFilter(logging.Filter):

+                 def filter(self, record):

+                     return False if record.funcName and record.funcName == 'is_excluded' else True

+ 

+             class ExcludingArchLogFilter(logging.Filter):

+                 def filter(self, record):

+                     if 'Populating package set for arch:' in record.message or \

+                             (record.funcName and record.funcName == 'is_excluded'):

+                         return True

+                     else:

+                         return False

+ 

+             for handler in logger.handlers:

+                 if isinstance(handler, logging.FileHandler):

+                     log_file_name = os.path.basename(handler.stream.name)

+                     if log_file_name == 'pungi.global.log':

+                         handler.addFilter(PungiLogFilter())

+                     elif log_file_name == 'excluding-arch.global.log':

+                         handler.addFilter(ExcludingArchLogFilter())

  

          # to provide compose_id, compose_date and compose_respin

          self.ci_base = ComposeInfo()

file modified
+2
@@ -369,6 +369,7 @@ 

          ci.return_value.compose.type_suffix = '.n'

  

          logger = mock.Mock()

+         logger.handlers = []

  

          conf = ConfigWrapper(

              variants_file={'scm': 'file',
@@ -433,6 +434,7 @@ 

      def setUp(self):

          self.tmp_dir = tempfile.mkdtemp()

          self.logger = mock.Mock()

+         self.logger.handlers = []

          with mock.patch('pungi.compose.ComposeInfo'):

              self.compose = Compose({}, self.tmp_dir, logger=self.logger)

  

There will be a new log file logs/global/excluding-arch.global.log

Fixes: https://pagure.io/pungi/issue/1251
Signed-off-by: Haibo Lin hlin@redhat.com

This is working nicely. Could you tweak the is_excluded function to also include the primary arch in the message? With the original message it was possible to know from where the package was excluded (by scrolling up to find a proper header), but this would now require comparing timestamps.

This is how I tested this: I added ExclusiveArch: x86_64 to dummy-basesystem.spec, ran make test-data and then make test-compose.

rebased onto 260df24

5 years ago

Included logs matching *Populating package set for arch: * to excluding-arch.global.log

Looks good to me. :thumbsup:

Pull-Request has been merged by lsedlar

5 years ago