From 6398becc856b43cbddb5bbfa7cb428848d2a70e2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 5 Nov 2010 10:42:05 -0700 Subject: [PATCH] Only log WARNING level messages (and more urgent ones) in pysawsim. --- pysawsim/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pysawsim/__init__.py b/pysawsim/__init__.py index 199b82a..9cb3a97 100644 --- a/pysawsim/__init__.py +++ b/pysawsim/__init__.py @@ -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) -- 2.26.2