Skip to content

Commit f14c4eb

Browse files
committed
chore: improve code structure in logging module
1 parent c3c6207 commit f14c4eb

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

freqtrade/loggers/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def setup_logging(config: Config) -> None:
7575
# config['logfilename']), which defaults to '/dev/log', applicable for most
7676
# of the systems.
7777
address = (s[1], int(s[2])) if len(s) > 2 else s[1] if len(s) > 1 else "/dev/log"
78-
handler_sl = get_existing_handlers(SysLogHandler)
79-
if handler_sl:
78+
if handler_sl := get_existing_handlers(SysLogHandler):
8079
logging.root.removeHandler(handler_sl)
8180
handler_sl = SysLogHandler(address=address)
8281
# No datetime field for logging into syslog, to allow syslog
@@ -92,8 +91,7 @@ def setup_logging(config: Config) -> None:
9291
"You need the cysystemd python package be installed in "
9392
"order to use logging to journald."
9493
)
95-
handler_jd = get_existing_handlers(JournaldLogHandler)
96-
if handler_jd:
94+
if handler_jd := get_existing_handlers(JournaldLogHandler):
9795
logging.root.removeHandler(handler_jd)
9896
handler_jd = JournaldLogHandler()
9997
# No datetime field for logging into journald, to allow syslog
@@ -102,8 +100,7 @@ def setup_logging(config: Config) -> None:
102100
handler_jd.setFormatter(Formatter("%(name)s - %(levelname)s - %(message)s"))
103101
logging.root.addHandler(handler_jd)
104102
else:
105-
handler_rf = get_existing_handlers(RotatingFileHandler)
106-
if handler_rf:
103+
if handler_rf := get_existing_handlers(RotatingFileHandler):
107104
logging.root.removeHandler(handler_rf)
108105
try:
109106
logfile_path = Path(logfile)

0 commit comments

Comments
 (0)