Add option to force DEBUG message to stderr
If the default log level for stderr is greater than DEBUG, DEBUG message won't be shown. The DEBUG(msg) function now takes an optional Boolean second parameter. If that is True, the DEBUG message is always sent to stderr.
This commit is contained in:
parent
dbf0c27a09
commit
e498457395
@ -20,7 +20,7 @@ class Config(object):
|
||||
ERRORS_TO = ['kae@midnighthax.com']
|
||||
FADE_STEPS = 20
|
||||
FADE_TIME = 3000
|
||||
LOG_LEVEL_STDERR = logging.DEBUG
|
||||
LOG_LEVEL_STDERR = logging.INFO
|
||||
LOG_LEVEL_SYSLOG = logging.DEBUG
|
||||
LOG_NAME = "musicmuster"
|
||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||
|
||||
16
app/log.py
16
app/log.py
@ -59,8 +59,20 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
|
||||
sys.excepthook = log_uncaught_exceptions
|
||||
|
||||
|
||||
def DEBUG(msg):
|
||||
log.debug(msg)
|
||||
def DEBUG(msg, force_stderr=False):
|
||||
"""
|
||||
Outupt a log message at level DEBUG. If force_stderr is True,
|
||||
output this message to stderr regardless of default stderr level
|
||||
setting.
|
||||
"""
|
||||
|
||||
if force_stderr:
|
||||
old_level = stderr.level
|
||||
stderr.setLevel(logging.DEBUG)
|
||||
log.debug(msg)
|
||||
stderr.setLevel(old_level)
|
||||
else:
|
||||
log.debug(msg)
|
||||
|
||||
|
||||
def EXCEPTION(msg):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user