From 8f7ebd8e388a96dd825ee3cc7a72850b51dbca8b Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 18 Feb 2013 17:45:07 +0000 Subject: Add option to config to enable/disable warnings in the logger, and fix the print statements in the logger to be the py3k print_function. --- src/leap/mx/util/config.py | 4 +++- src/leap/mx/util/log.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/leap/mx/util/config.py b/src/leap/mx/util/config.py index f655ca9..f0f1bbb 100644 --- a/src/leap/mx/util/config.py +++ b/src/leap/mx/util/config.py @@ -87,6 +87,8 @@ def _create_config_file(conffile): # basic: + # Should we print warnings to stdout and, if enabled, the logfile?: + show_warnings: True # Whether or not to log to file: enable_logfile: True # The name of the logfile: @@ -111,7 +113,7 @@ advanced: debug: True # Print enough things really fast to make you look super 1337: noisy: False -config_version: 0.0.2 +config_version: 0.0.3 """) conf.flush() diff --git a/src/leap/mx/util/log.py b/src/leap/mx/util/log.py index f31684d..4f2b4e5 100644 --- a/src/leap/mx/util/log.py +++ b/src/leap/mx/util/log.py @@ -9,6 +9,8 @@ Logging for leap_mx. @copyright: 2013 Isis Agora Lovecruft ''' +from __future__ import print_function + from datetime import datetime from functools import wraps @@ -85,22 +87,22 @@ def start(logfilename=None, logfiledir=None): def msg(msg, *arg, **kwarg): """Log a message at the INFO level.""" - print "[*] %s" % msg + print("[*] %s" % msg) def debug(msg, *arg, **kwarg): """Log a message at the DEBUG level.""" if config.advanced.debug: - print "[d] %s" % msg + print("[d] %s" % msg) def warn(msg, *arg, **kwarg): """Log a message at the WARN level.""" if config.basic.show_warnings: txlog.logging.captureWarnings('true') - print "[#] %s" % msg + print("[#] %s" % msg) def err(msg, *arg, **kwarg): """Log a message at the ERROR level.""" - print "[!] %s" % msg + print("[!] %s" % msg) def fail(*failure): """Log a message at the CRITICAL level.""" -- cgit v1.2.3