Skip to content

Commit

Permalink
Added log phase to logger task output
Browse files Browse the repository at this point in the history
  • Loading branch information
Venefilyn committed Sep 18, 2024
1 parent c0e3b02 commit e272c18
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions convert2rhel/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from logging.handlers import BufferingHandler
from time import gmtime, strftime

from convert2rhel.utils.phase import ConversionPhases


LOG_DIR = "/var/log/convert2rhel"

Expand Down Expand Up @@ -283,8 +285,15 @@ def format(self, record):

color = self._getLogLevelColor(record, is_task)
if is_task:
asterisks = "*" * (90 - len(record.msg) - 25)
fmt_orig = "\n[%(asctime)s] TASK - [%(message)s] " + asterisks
log_phase_name = ""
if ConversionPhases.current_phase and ConversionPhases.current_phase.log_name:
log_phase_name = ConversionPhases.current_phase.log_name
asterisks = "*" * (90 - len(log_phase_name) - len(record.msg) - 25)

fmt_orig = "\n[%(asctime)s] TASK - [{log_phase_name}%(message)s] {asterisks}".format(
log_phase_name=log_phase_name, asterisks=asterisks
)

self.datefmt = "%Y-%m-%dT%H:%M:%S%z"
elif record.levelno >= logging.WARNING:
fmt_orig = "%(levelname)s - %(message)s"
Expand Down

0 comments on commit e272c18

Please sign in to comment.