Skip to content

Commit

Permalink
Fixed default log level and added date info to log messages
Browse files Browse the repository at this point in the history
- log level bug: #32
- date feature: #6
  • Loading branch information
mkcn committed Jan 16, 2021
1 parent f48d0f6 commit 323bbf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions fastHistory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,15 @@ def retrieve_parameters_from_bash_hook(arg1=None):

def handle_arguments(logger_console, config_reader, path_data_folder, path_code_folder):
# set logging (this setting is applied globally for all logging calls from now on)
logging.basicConfig(filename=path_data_folder + NAME_LOG_FILE, level=config_reader.get_log_level())
if config_reader.get_log_level() == 'NOTSET' or config_reader.get_log_level() == 'NONE':
logging.disable(logging.CRITICAL)
else:
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
filename=path_data_folder + NAME_LOG_FILE,
level=config_reader.get_log_level())
logging.debug("bash input: %s" % str(sys.argv))

logger_console.set_theme(config_reader.get_theme())

args_len = len(sys.argv)
# check number of parameters
if args_len == 1:
Expand Down
3 changes: 2 additions & 1 deletion fastHistory/config/configReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class used to read the configuration file
THEME_AZURE = "AZURE"
THEME_GREEN = "GREEN"

_ALLOWED_LOG_LEVELS = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'NOTSET']
# NOTSET may be used by old configutation files ( <= 2.1.5) and it must be considered equal to NONE
_ALLOWED_LOG_LEVELS = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'NOTSET', 'NONE']
_ALLOWED_THEME = [THEME_AZURE, THEME_GREEN]

_config = None
Expand Down
6 changes: 3 additions & 3 deletions fastHistory/config/default_fastHistory.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#################################################################
[GENERAL]
# general settings
# log options: NOTSET > CRITICAL > ERROR > WARNING > INFO > DEBUG
# log options: NONE, CRITICAL, ERROR, WARNING, INFO, DEBUG
# theme options: AZURE or GREEN
# tags column options: from 0 (%) to 50 (%)
# tags column size: from 0 (%) to 50 (%)
#################################################################
LOG_LEVEL = NOTSET
LOG_LEVEL = NONE
THEME = AZURE
TAGS_COLUMN_SIZE = 35

0 comments on commit 323bbf1

Please sign in to comment.