Skip to content

Commit 291eaea

Browse files
committed
fix: do not format log result if no log will be printed
this is still not perfect, but will save some CPU cycles.
1 parent e3ecba3 commit 291eaea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pyaptly/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def run_command(
128128
tb = write_traceback() # pragma: no cover
129129
raise
130130
finally:
131-
if result:
131+
if result and lg.getEffectiveLevel() <= logging.DEBUG:
132132
log_msg = format_run_result(result, result.returncode, tb)
133133
if result.returncode == 0:
134134
lg.info(log_msg)
135135
else:
136-
if not hide_error or lg.root.level <= 20:
136+
if not hide_error or lg.getEffectiveLevel() <= logging.INFO:
137137
lg.error(log_msg)
138138
# This function should not alter the returned result
139139
if added_stdout:

0 commit comments

Comments
 (0)