I wrote a function, which runs external commands and captures their outputs, something like this
proc = subprocess.run(command_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if proc.returncode != 0:
Unfortunately, I don't see long commands output as they running. How to do this conditionally, for example, if loglevel is debug or higher?