From: Michael Tremer Date: Tue, 1 Nov 2022 12:56:43 +0000 (+0000) Subject: pakfire: Setup logging on regular CLI tool X-Git-Tag: 0.9.28~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2279f2f2ca4c64f989f61b611e3e901b731fd920;p=pakfire.git pakfire: Setup logging on regular CLI tool Signed-off-by: Michael Tremer --- diff --git a/src/scripts/pakfire.in b/src/scripts/pakfire.in index 330087c97..1412cc1fb 100644 --- a/src/scripts/pakfire.in +++ b/src/scripts/pakfire.in @@ -25,6 +25,7 @@ import sys import pakfire import pakfire.errors +import pakfire.logger from pakfire.i18n import _ class Cli(object): @@ -55,6 +56,10 @@ class Cli(object): parser.add_argument("--arch", "-a", nargs="?", help=_("Run pakfire for the given architecture")) + # Debug Mode + parser.add_argument("--debug", action="store_true", + help=_("Enable debug mode")) + # Root parser.add_argument("--root", metavar="PATH", default="/", help=_("The path where pakfire should operate in")) @@ -241,12 +246,21 @@ class Cli(object): # Parse command line arguments args = self.parse_cli() + # Setup logger + logger = pakfire.logger.setup( + "pakfire", + syslog_identifier="pakfire", + enable_console=True, + debug=args.debug, + ) + # Create Pakfire instance p = pakfire.Pakfire( conf=args.config, arch=args.arch, path=args.root, offline=args.offline, + logger=logger.log, ) # Disable repositories