From 30fdcceea3efbd264b00d78fb0f86fd5a2ff8831 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 6 Jun 2022 14:45:41 +0200 Subject: src: improve logging Adds new logging handler redirecting messages to the log file located in the Samba shared directory (applies to live mode clients, i.e: ogLive) Parses log level configuration from ogclient.json. See: { "opengnsys": { ... "log": "INFO", ... } ... } Adds --debug option to set root logger level to DEBUG when starting ogClient. Overrides log level from config file. In addition: - Replaces any occurence of print with a corresponding logging function. - Unsets log level for handlers, use root logger level instead. - Default level for root logger is INFO. - Replaces level from response log messages to debug (ogRest) --- ogclient | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'ogclient') diff --git a/ogclient b/ogclient index be7a7f1..8798ed6 100755 --- a/ogclient +++ b/ogclient @@ -46,6 +46,9 @@ def create_parser(): parser.add_argument('-c', '--config', default="", help='ogClient JSON config file path') + parser.add_argument('--debug', default=False, + action='store_true', + help='enables debug log level') return parser @@ -73,12 +76,17 @@ def main(): MODE = CONFIG['opengnsys']['mode'] URL = CONFIG['opengnsys']['url'] + LOGLEVEL = CONFIG['opengnsys']['log'] + if MODE == 'live': proc = subprocess.Popen(["browser", "-qws", URL]) if MODE != 'windows': signal.signal(SIGPIPE, SIG_DFL) - configure_logging(MODE) + configure_logging(MODE, LOGLEVEL) + + if args.debug: + logging.getLogger().setLevel('DEBUG') client = ogClient(config=CONFIG) client.connect() -- cgit v1.2.3-18-g5258