From 2d6d3d68f6ae9850687eebdfeaf9e175abd577fb Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Tue, 2 Jun 2015 23:37:00 +0800 Subject: [PATCH 1/2] set log level from config file Read the log level settings from the "loglevel" value in the "bitmessagesettings" section of the config file. The possible values map directly to the ones allowed by the logger module: DEBUG, INFO, WARNING, ERROR, CRITICAL Only allow these values, and cast to upper case to be more easy going in the settings. --- src/debug.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debug.py b/src/debug.py index 30c64ea4..99644066 100644 --- a/src/debug.py +++ b/src/debug.py @@ -24,7 +24,9 @@ import helper_startup helper_startup.loadConfig() # TODO(xj9): Get from a config file. -log_level = 'DEBUG' +possible_log_levels = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] +config_log_level = shared.config.get('bitmessagesettings', 'loglevel').upper() +log_level = config_log_level if config_log_level in possible_log_levels else 'DEBUG' def configureLogging(): logging.config.dictConfig({ -- 2.45.1 From e3f9af381fd43da9d532bb4763e63ac1ccea6cf8 Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Wed, 3 Jun 2015 11:32:28 +0800 Subject: [PATCH 2/2] add default loglevel in case it's not set in config file --- src/shared.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared.py b/src/shared.py index d82f00a5..3053b6af 100644 --- a/src/shared.py +++ b/src/shared.py @@ -34,7 +34,9 @@ import shared from helper_sql import * -config = ConfigParser.SafeConfigParser() +config = ConfigParser.SafeConfigParser( + defaults={'loglevel':'DEBUG' + }) myECCryptorObjects = {} MyECSubscriptionCryptorObjects = {} myAddressesByHash = {} #The key in this dictionary is the RIPE hash which is encoded in an address and value is the address itself. -- 2.45.1