Commit 45cacfac authored by Jérome Perrin's avatar Jérome Perrin

supports logging to a file

parent 7e4f8643
Pipeline #32354 passed with stage
in 0 seconds
......@@ -65,9 +65,12 @@ def application(global_config, **local_config):
local_config["env"] = environment_dict
gc.enable()
util.configureLogger(debug_mode=util.convertStringToBool(
util.configureLogger(
debug_mode=util.convertStringToBool(
# .lower() is for backward compatibility
local_config.get('debug_mode', 'false').lower()))
local_config.get('debug_mode', 'false').lower()),
logfile=local_config.get('logfile')
)
# path of directory to run cloudooo
working_path = local_config.get('working_path')
if not path.exists(working_path):
......
......@@ -60,7 +60,7 @@ def loadMimetypeList():
mimetypes.init(files=[mime_types_url, ])
def configureLogger(level=None, debug_mode=False):
def configureLogger(level=None, debug_mode=False, logfile=None):
"""Configure logger.
Keyword arguments:
level -- Level to prints the log messages
......@@ -82,7 +82,10 @@ def configureLogger(level=None, debug_mode=False):
logger.propagate = 0
logger.setLevel(level)
# create console handler and set level to debug
ch = logging.StreamHandler()
if logfile:
ch = logging.FileHandler(logfile)
else:
ch = logging.StreamHandler()
ch.setLevel(level)
# create formatter
format = "%(asctime).19s - %(name)s - %(levelname)s - %(message)s"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment