]> git.ipfire.org Git - pakfire.git/commitdiff
cli: execute: Log output to console
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 May 2021 12:55:40 +0000 (12:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 May 2021 12:55:40 +0000 (12:55 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/cli.py

index cb2ad6ec9506410a0b8397257cc05d54f3f01560..0b2bb17666c8e1badd2ebb9d3836e1aa7c7ea690 100644 (file)
@@ -222,7 +222,14 @@ class Cli(object):
                for bind in ns.binds:
                        pakfire.bind(bind)
 
-               return pakfire.execute(ns.command)
+               # Log everything to the console
+               def logging_callback(level, line):
+                       if level >= logging.ERROR:
+                               sys.stderr.write("%s\n" % line)
+                       else:
+                               sys.stdout.write("%s\n" % line)
+
+               return pakfire.execute(ns.command, logging_callback=logging_callback)
 
        def run(self):
                args = self.parse_cli()