From: W. Trevor King Date: Fri, 5 Nov 2010 17:42:05 +0000 (-0700) Subject: Only log WARNING level messages (and more urgent ones) in pysawsim. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6398becc856b43cbddb5bbfa7cb428848d2a70e2;p=sawsim.git Only log WARNING level messages (and more urgent ones) in pysawsim. --- 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)