From 01ddec2fdc92a2058af09c81b3b8c247062c3eb8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 16 Aug 2024 17:23:31 +0200 Subject: [PATCH] contrib/saip-tool: Add command-line arguments to configure log level Change-Id: I4257d7b76193cdaad8c8571ff49f29067e8ab8c8 --- contrib/saip-tool.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py index 22b913e6..7b574881 100755 --- a/contrib/saip-tool.py +++ b/contrib/saip-tool.py @@ -31,11 +31,12 @@ from pySim.pprint import HexBytesPrettyPrinter pp = HexBytesPrettyPrinter(indent=4,width=500) -logging.basicConfig(level=logging.INFO) - parser = argparse.ArgumentParser(description=""" Utility program to work with eSIM SAIP (SimAlliance Interoperable Profile) files.""") parser.add_argument('INPUT_UPP', help='Unprotected Profile Package Input file') +parser.add_argument("--loglevel", dest="loglevel", choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], + default='INFO', help="Set the logging level") +parser.add_argument('--debug', action='store_true', help='Enable DEBUG logging') subparsers = parser.add_subparsers(dest='command', help="The command to perform", required=True) parser_split = subparsers.add_parser('split', help='Split PE-Sequence into individual PEs') @@ -225,6 +226,11 @@ def do_extract_apps(pes:ProfileElementSequence, opts): if __name__ == '__main__': opts = parser.parse_args() + if opts.debug: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.getLevelName(opts.loglevel)) + with open(opts.INPUT_UPP, 'rb') as f: pes = ProfileElementSequence.from_der(f.read())