Skip to content

Commit

Permalink
Format indent
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinavcode13 authored May 26, 2024
1 parent 504ff25 commit b6852e0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/polyphy/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime
import logging
import time
from logging.handlers import RotatingFileHandler


class Logger:
Expand Down Expand Up @@ -45,6 +46,7 @@ def logToStdOut(level, *msg) -> None:
# FILE:
file_logger = logging.getLogger("file")
file_handler = logging.FileHandler("polyphy.log")
file_handler = RotatingFileHandler("polyphy.log", maxBytes=1024*1024, backupCount=3)
file_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
file_handler.setFormatter(file_formatter)
file_logger.addHandler(file_handler)
Expand All @@ -64,14 +66,12 @@ def logToFile(level, *msg) -> None:

@staticmethod
def logException(level, exception, *msg) -> None:
log_msg = " ".join(map(str, msg))
log_msg += f"\nException: {repr(exception)}"
log_msg += f"\nStack Trace: {traceback.format_exc()}"

# Construct log message with exception info
log_msg = " ".join(map(str, msg))
log_msg += f"\nException: {repr(exception)}"
log_msg += f"\nStack Trace: {traceback.format_exc()}"

# Log to console
Logger.logToStdOut(level, log_msg)

# Log to file
Logger.logToFile(level, log_msg)
# Log to console
Logger.logToStdOut(level, log_msg)

# Log to file
Logger.logToFile(level, log_msg)

0 comments on commit b6852e0

Please sign in to comment.