Make it possible to log events to stdout without logging to file.

This commit is contained in:
Arik Fraimovich 2014-04-10 13:04:03 +03:00
parent 5a0f524b5e
commit 9b8c3872c6
2 changed files with 6 additions and 6 deletions

View File

@ -20,8 +20,7 @@ def setup_logging():
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(settings.LOG_LEVEL)
if settings.EVENTS_LOG_PATH:
events.setup_logging(settings.EVENTS_LOG_PATH, settings.EVENTS_CONSOLE_OUTPUT)
events.setup_logging(settings.EVENTS_LOG_PATH, settings.EVENTS_CONSOLE_OUTPUT)
setup_logging()

View File

@ -6,10 +6,11 @@ logger.propagate = False
def setup_logging(log_path, console_output=False):
fh = logging.FileHandler(log_path)
formatter = logging.Formatter('%(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)
if log_path:
fh = logging.FileHandler(log_path)
formatter = logging.Formatter('%(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)
if console_output:
handler = logging.StreamHandler()