Skip to content

Commit

Permalink
Make log formatting a bit more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacG committed Feb 16, 2025
1 parent 2b2b393 commit f7e5ccc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions everybody_codes/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class LogFormatter(logging.Formatter):
def __init__(self, day: int, *args, **kwargs):
def __init__(self, day: int = 0, *args, **kwargs):
super().__init__(*args, **kwargs)
self.last_call = time.perf_counter_ns()
self.day = day
Expand All @@ -25,7 +25,10 @@ def set_part(self, part: int) -> None:
self.part = part

def format(self, record) -> str:
return super().format(record).replace("DAYPART", f"{self.day}.{self.part}")
msg = super().format(record)
if "DAYPART" in msg and self.day and self.part:
msg = msg.replace("DAYPART", f"{self.day}.{self.part}")
return msg

def formatTime(self, record, datefmt=None):
if datefmt:
Expand Down

0 comments on commit f7e5ccc

Please sign in to comment.