Skip to content

Commit

Permalink
chore: improve code structure in logging module
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Feb 15, 2025
1 parent c3c6207 commit f14c4eb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions freqtrade/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def setup_logging(config: Config) -> None:
# config['logfilename']), which defaults to '/dev/log', applicable for most
# of the systems.
address = (s[1], int(s[2])) if len(s) > 2 else s[1] if len(s) > 1 else "/dev/log"
handler_sl = get_existing_handlers(SysLogHandler)
if handler_sl:
if handler_sl := get_existing_handlers(SysLogHandler):
logging.root.removeHandler(handler_sl)
handler_sl = SysLogHandler(address=address)
# No datetime field for logging into syslog, to allow syslog
Expand All @@ -92,8 +91,7 @@ def setup_logging(config: Config) -> None:
"You need the cysystemd python package be installed in "
"order to use logging to journald."
)
handler_jd = get_existing_handlers(JournaldLogHandler)
if handler_jd:
if handler_jd := get_existing_handlers(JournaldLogHandler):
logging.root.removeHandler(handler_jd)
handler_jd = JournaldLogHandler()
# No datetime field for logging into journald, to allow syslog
Expand All @@ -102,8 +100,7 @@ def setup_logging(config: Config) -> None:
handler_jd.setFormatter(Formatter("%(name)s - %(levelname)s - %(message)s"))
logging.root.addHandler(handler_jd)
else:
handler_rf = get_existing_handlers(RotatingFileHandler)
if handler_rf:
if handler_rf := get_existing_handlers(RotatingFileHandler):
logging.root.removeHandler(handler_rf)
try:
logfile_path = Path(logfile)
Expand Down

0 comments on commit f14c4eb

Please sign in to comment.