From 3dfe54968b6e50d5b85391bd9302c2a4f0a21aa3 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 18 Nov 2021 10:29:46 +0100 Subject: #1065 Use logging module instead of syslog We can't use syslog if we want to execute ogClient in the Windows platform. Use the native logging library so we can attach different handlers depending on the mode ogClient is executing. Logging configuration is done via a python dict. There is a different dict for linux and windows. These dicts define the configuration of the root logger, handlers and formatters used. As of now, it is only expected to use the root logger for everything logging related. The root logger is obtained via: LOGGER = logging.getLogger() More info about handlers, formatters and loggers: https://docs.python.org/3/howto/logging.html Logging configuration is done at startup, just after parsing the json (knowing ogclient mode). If json parsing goes bad, ogclient will only print a message to stdout. --- ogclient | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ogclient') diff --git a/ogclient b/ogclient index 528a0e4..4f8ca56 100755 --- a/ogclient +++ b/ogclient @@ -18,6 +18,7 @@ except ImportError: from src.ogClient import * +from src.log import configure_logging def main(): @@ -36,6 +37,8 @@ def main(): if MODE != 'windows': signal.signal(SIGPIPE, SIG_DFL) + configure_logging(MODE) + client = ogClient(config=CONFIG) client.connect() client.run() -- cgit v1.2.3-18-g5258