making loglevel configurable for local logging
This commit is contained in:
@@ -48,10 +48,12 @@ for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items():
|
||||
MITX_FEATURES[feature] = value
|
||||
|
||||
WIKI_ENABLED = ENV_TOKENS.get('WIKI_ENABLED', WIKI_ENABLED)
|
||||
local_loglevel = ENV_TOKENS.get('LOCAL_LOGLEVEL', 'INFO')
|
||||
|
||||
LOGGING = get_logger_config(LOG_DIR,
|
||||
logging_env=ENV_TOKENS['LOGGING_ENV'],
|
||||
syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
|
||||
local_loglevel=local_loglevel,
|
||||
debug=False)
|
||||
|
||||
COURSE_LISTINGS = ENV_TOKENS.get('COURSE_LISTINGS', {})
|
||||
|
||||
@@ -8,13 +8,19 @@ def get_logger_config(log_dir,
|
||||
logging_env="no_env",
|
||||
tracking_filename=None,
|
||||
syslog_addr=None,
|
||||
debug=False):
|
||||
debug=False,
|
||||
local_loglevel='INFO'):
|
||||
|
||||
"""Return the appropriate logging config dictionary. You should assign the
|
||||
result of this to the LOGGING var in your settings. The reason it's done
|
||||
this way instead of registering directly is because I didn't want to worry
|
||||
about resetting the logging state if this is called multiple times when
|
||||
settings are extended."""
|
||||
|
||||
# Revert to INFO if an invalid string is passed in
|
||||
if local_loglevel not in ['DEBUG','INFO','WARNING','ERROR','CRITICAL']:
|
||||
local_loglevel = 'INFO'
|
||||
|
||||
# If we're given an explicit place to put tracking logs, we do that (say for
|
||||
# debugging). However, logging is not safe for multiple processes hitting
|
||||
# the same file. So if it's left blank, we dynamically create the filename
|
||||
@@ -56,7 +62,7 @@ def get_logger_config(log_dir,
|
||||
'formatter' : 'syslog_format',
|
||||
},
|
||||
'syslogger-local' : {
|
||||
'level' : 'DEBUG',
|
||||
'level' : local_loglevel,
|
||||
'class' : 'logging.handlers.SysLogHandler',
|
||||
'address' : '/dev/log',
|
||||
'formatter' : 'syslog_format',
|
||||
|
||||
Reference in New Issue
Block a user