insndb/db: support log option
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Jun 2023 15:15:42 +0000 (18:15 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000 (19:26 +0000)
src/openpower/insndb/db.py

index 1ddb578e7ccb28a63c7e5ad0e83054e5f04330ce..ed9063daff93bc0095b963e117acf4fca68552c0 100644 (file)
@@ -1,6 +1,6 @@
 import argparse
 import contextlib
-import sys
+import os
 
 from openpower.decoder.power_enums import (
     find_wiki_dir,
@@ -59,7 +59,12 @@ def main():
         "opcodes": OpcodesVisitor,
         "operands": OperandsVisitor,
     }
+
     main_parser = argparse.ArgumentParser()
+    main_parser.add_argument("-l", "--log",
+        help="activate logging",
+        action="store_true",
+        default=False)
     main_subparser = main_parser.add_subparsers(dest="command", required=True)
     main_subparser.add_parser("list",
         help="list all instructions")
@@ -73,6 +78,9 @@ def main():
 
     args = vars(main_parser.parse_args())
     command = args.pop("command")
+    log = args.pop("log")
+    if not log:
+        os.environ["SILENCELOG"] = "true"
     visitor = visitors[command](**args)
 
     db = Database(find_wiki_dir())