Skip to content

Commit

Permalink
Merge pull request #200 from caitaozhan/master
Browse files Browse the repository at this point in the history
[minor] remove existing handlers in logging
  • Loading branch information
caitaozhan authored Nov 20, 2024
2 parents d33414c + 0d4169a commit 310bead
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sequence/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _init_logger():
return lg


logger = _init_logger()
logger = _init_logger() # global logger
# LOG_FORMAT = '{asctime} {simtime:<20,} {levelname:7} {module:20} {message}'
LOG_FORMAT = '{simtime:<20,} {levelname:7} {module:20} {message}' # no asctime
_log_modules = []
Expand All @@ -40,6 +40,10 @@ def set_logger(name: str, timeline, logfile="out.log"):
global logger
logger = logging.getLogger(name)

# remove existing handleers
for h in logger.handlers:
logger.removeHandler(h)

handler = logging.FileHandler(logfile)
fmt = logging.Formatter(LOG_FORMAT, style='{')
f = ContextFilter(timeline)
Expand Down

0 comments on commit 310bead

Please # to comment.