Commit 8577280b authored by Jérome Perrin's avatar Jérome Perrin

supports logging to a file

parent c249c833
...@@ -65,9 +65,12 @@ def application(global_config, **local_config): ...@@ -65,9 +65,12 @@ def application(global_config, **local_config):
local_config["env"] = environment_dict local_config["env"] = environment_dict
gc.enable() gc.enable()
util.configureLogger(debug_mode=util.convertStringToBool( util.configureLogger(
debug_mode=util.convertStringToBool(
# .lower() is for backward compatibility # .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 # path of directory to run cloudooo
working_path = local_config.get('working_path') working_path = local_config.get('working_path')
if not path.exists(working_path): if not path.exists(working_path):
......
...@@ -60,7 +60,7 @@ def loadMimetypeList(): ...@@ -60,7 +60,7 @@ def loadMimetypeList():
mimetypes.init(files=[mime_types_url, ]) mimetypes.init(files=[mime_types_url, ])
def configureLogger(level=None, debug_mode=False): def configureLogger(level=None, debug_mode=False, logfile=None):
"""Configure logger. """Configure logger.
Keyword arguments: Keyword arguments:
level -- Level to prints the log messages level -- Level to prints the log messages
...@@ -82,6 +82,9 @@ def configureLogger(level=None, debug_mode=False): ...@@ -82,6 +82,9 @@ def configureLogger(level=None, debug_mode=False):
logger.propagate = 0 logger.propagate = 0
logger.setLevel(level) logger.setLevel(level)
# create console handler and set level to debug # create console handler and set level to debug
if logfile:
ch = logging.FileHandler(logfile)
else:
ch = logging.StreamHandler() ch = logging.StreamHandler()
ch.setLevel(level) ch.setLevel(level)
# create formatter # create formatter
......
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