Setup of logging from a configuration file. Refer to the following for the details of a configuration file. http://docs.python.org/2/library/logging.config.html
Signed-off-by: Satoshi Kobayashi <[email protected]> --- ryu/log.py | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/ryu/log.py b/ryu/log.py index d02d4fc..0f13453 100644 --- a/ryu/log.py +++ b/ryu/log.py @@ -17,6 +17,7 @@ from oslo.config import cfg import inspect import logging +import logging.config import logging.handlers import os import sys @@ -32,7 +33,9 @@ CONF.register_cli_opts([ cfg.StrOpt('log-dir', default=None, help='log file directory'), cfg.StrOpt('log-file', default=None, help='log file name'), cfg.StrOpt('log-file-mode', default='0644', - help='default log file permission') + help='default log file permission'), + cfg.StrOpt('log-config-file', default=None, + help='Path to a logging config file to use') ]) @@ -62,6 +65,13 @@ def init_log(): global _EARLY_LOG_HANDLER log = logging.getLogger() + + if CONF.log_config_file: + for handler in log.handlers: + log.removeHandler(handler) + logging.config.fileConfig(CONF.log_config_file) + return + if CONF.use_stderr: log.addHandler(logging.StreamHandler(sys.stderr)) if _EARLY_LOG_HANDLER is not None: -- 1.7.1 ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
