From b7cd5247868beae255f90f71edf2de3eb8dcaf6e Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Tue, 16 Feb 2021 18:45:46 +0000 Subject: [PATCH] Fix logg_levels --- config.yml | 1 + gmnd/__init__.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 341ffb6..b24981f 100644 --- a/config.yml +++ b/config.yml @@ -1,3 +1,4 @@ --- allow_dir_list: true listen_addr: '0.0.0.0' +logg_level: 'DEBUG' diff --git a/gmnd/__init__.py b/gmnd/__init__.py index c40acf5..2c2a2e9 100644 --- a/gmnd/__init__.py +++ b/gmnd/__init__.py @@ -24,6 +24,7 @@ class gMNd: if self.config_file: if os.path.isfile(self.config_file): self.read_config() + logging.basicConfig(stream=sys.stderr, level=self.logg_level) else: logging.warning("Config file supplied, but it is not a file") self.bindsocket = socket.socket() @@ -43,7 +44,18 @@ class gMNd: if 'listen_port' in config_dict: self.listen_port = config_dict['listen_port'] if 'logg_level' in config_dict: - self.logg_level = config_dict['logg_level'] + if config_dict['logg_level'] == "CRITICAL": + self.logg_level = logging.CRITICAL + elif config_dict['logg_level'] == "DEBUG": + self.logg_level = logging.DEBUG + elif config_dict['logg_level'] == "ERROR": + self.logg_level = logging.ERROR + elif config_dict['logg_level'] == "INFO": + self.logg_level = logging.INFO + elif config_dict['logg_level'] == "NOTSET": + self.logg_level = logging.NOTSET + elif config_dict['logg_level'] == "WARNING": + self.logg_level = logging.WARNING if 'server_cert' in config_dict: self.server_cert = config_dict['server_cert'] if 'server_key' in config_dict: