Only log WARNING level messages (and more urgent ones) in pysawsim.
authorW. Trevor King <wking@drexel.edu>
Fri, 5 Nov 2010 17:42:05 +0000 (10:42 -0700)
committerW. Trevor King <wking@drexel.edu>
Fri, 5 Nov 2010 17:42:05 +0000 (10:42 -0700)
pysawsim/__init__.py

index 199b82a65acfdc78248cf441ffcb5de8cfd5fe5b..9cb3a97a5311b8ccc2f6dc31c730c27e4c0e6f39 100644 (file)
@@ -62,12 +62,12 @@ __version__ = '0.10'  # match sawsim version
 def log():
     return logging.getLogger('pysawsim')
 
-_log = log()
-_log.setLevel(logging.DEBUG)
-_console = logging.StreamHandler()
-_formatter = logging.Formatter('%(name)-8s: %(levelname)-6s %(message)s')
-_console.setFormatter(_formatter)
-_log.addHandler(_console)
-del(_log)
-del(_console)
-del(_formatter)
+def add_stderr_log_handler(level=logging.DEBUG):
+    _log = log()
+    _log.setLevel(level)
+    console = logging.StreamHandler()
+    formatter = logging.Formatter('%(name)-8s: %(levelname)-6s %(message)s')
+    console.setFormatter(formatter)
+    _log.addHandler(console)
+
+add_stderr_log_handler(logging.WARNING)