| |
@@ -82,6 +82,8 @@
|
| |
def setup_logging():
|
| |
root_logger = logging.getLogger('')
|
| |
root_logger.setLevel(logging.DEBUG)
|
| |
+ root_logger.handlers.clear()
|
| |
+ app.logger.handlers.clear()
|
| |
|
| |
if app.config['STREAM_LOGGING']:
|
| |
app.logger.debug("doing stream logging")
|
| |
@@ -89,7 +91,6 @@
|
| |
stream_handler.setLevel(loglevel)
|
| |
stream_handler.setFormatter(formatter)
|
| |
root_logger.addHandler(stream_handler)
|
| |
- app.logger.addHandler(stream_handler)
|
| |
|
| |
if app.config['SYSLOG_LOGGING']:
|
| |
app.logger.debug("doing syslog logging")
|
| |
@@ -98,7 +99,6 @@
|
| |
syslog_handler.setLevel(loglevel)
|
| |
syslog_handler.setFormatter(formatter)
|
| |
root_logger.addHandler(syslog_handler)
|
| |
- app.logger.addHandler(syslog_handler)
|
| |
|
| |
if app.config['FILE_LOGGING'] and app.config['LOGFILE']:
|
| |
app.logger.debug("doing file logging to %s" % app.config['LOGFILE'])
|
| |
@@ -106,8 +106,6 @@
|
| |
file_handler.setLevel(loglevel)
|
| |
file_handler.setFormatter(formatter)
|
| |
root_logger.addHandler(file_handler)
|
| |
- app.logger.addHandler(file_handler)
|
| |
-
|
| |
|
| |
setup_logging()
|
| |
|
| |
Before this patch, all messages logged with
logging.getLogger('foo')
wereprinted once, but all messages logged with
app.logger
were printed triplicated.The reason was that
a) the
app.logger
is initialized with stream logging enabled by default, sowe were adding it the second time
b) everything sent to the
app.logger
goes also through theroot_logger
whichwas also configured with the same handlers, which resulted in one extra message
The fix is to clean all handlers on program start, so that default handlers are
removed. And then only add handlers to the
root_logger
and not also to theapp.logger
, because the message passes both whenapp.logger
is invoked.