Permalink
Browse files

Changes to logging

There are more changes to be made; specifically, I think log
config files should be moved to the log module, and the disabling-by-
default should maybe change.
  • Loading branch information...
1 parent b4310f1 commit 8fab5f5ca5b9c9b5fb4fa90e337ce7d26d9d61c8 @MurphyMc MurphyMc committed May 6, 2012
Showing with 10 additions and 32 deletions.
  1. +0 −22 logging.cfg
  2. +10 −10 pox.py
View
@@ -1,22 +0,0 @@
-[loggers]
-keys=root
-
-[handlers]
-keys=consoleHandler
-
-[formatters]
-keys=simpleFormatter
-
-[logger_root]
-level=INFO
-handlers=consoleHandler
-
-[handler_consoleHandler]
-class=StreamHandler
-level=DEBUG
-formatter=simpleFormatter
-args=(sys.stdout,)
-
-[formatter_simpleFormatter]
-format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
-datefmt=
View
20 pox.py
@@ -330,21 +330,21 @@ def prep (self):
pass
def setup_logging(log_config="logging.cfg", fail_if_non_existent=False):
+ # This is kind of a hack, but we need to keep track of the handler we
+ # install so that we can, for example, uninstall it later. This code
+ # originally lived in pox.core, so we explicitly reference it here.
+ pox.core._default_log_handler = logging.StreamHandler()
+ formatter = logging.Formatter(logging.BASIC_FORMAT)
+ pox.core._default_log_handler.setFormatter(formatter)
+ logging.getLogger().addHandler(pox.core._default_log_handler)
+ logging.getLogger().setLevel(logging.DEBUG)
+
if os.path.exists(log_config):
- logging.config.fileConfig(log_config)
+ logging.config.fileConfig(log_config, disable_existing_loggers=True)
else:
if fail_if_non_existent:
raise IOError("Could not find logging config file: %s" % (log_config,))
- # This is kind of a hack, but we need to keep track of the handler we
- # install so that we can, for example, uninstall it later. This code
- # originally lived in pox.core, so we explicitly reference it here.
- pox.core._default_log_handler = logging.StreamHandler()
- formatter = logging.Formatter(logging.BASIC_FORMAT)
- pox.core._default_log_handler.setFormatter(formatter)
- logging.getLogger().addHandler(pox.core._default_log_handler)
- logging.getLogger().setLevel(logging.DEBUG)
-
def main ():
setup_logging()
_monkeypatch_console()

0 comments on commit 8fab5f5

Please sign in to comment.