diff options
Diffstat (limited to 'numpy/distutils/log.py')
-rw-r--r-- | numpy/distutils/log.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/numpy/distutils/log.py b/numpy/distutils/log.py index 7484f1f5e..2e5af94a2 100644 --- a/numpy/distutils/log.py +++ b/numpy/distutils/log.py @@ -4,7 +4,7 @@ import sys from distutils.log import * from distutils.log import Log as old_Log from distutils.log import _global_log -from misc_util import red_text, yellow_text, cyan_text, is_sequence, is_string +from misc_util import red_text, yellow_text, cyan_text, green_text, is_sequence, is_string def _fix_args(args,flag=1): @@ -22,8 +22,29 @@ class Log(old_Log): else: print _global_color_map[level](msg) sys.stdout.flush() + + def good(self, msg, *args): + """If we'd log WARN messages, log this message as a 'nice' anti-warn + message. + """ + if WARN >= self.threshold: + if args: + print green_text(msg % _fix_args(args)) + else: + print green_text(msg) + sys.stdout.flush() _global_log.__class__ = Log +good = _global_log.good + +def set_threshold(level): + prev_level = _global_log.threshold + if prev_level > DEBUG: + # If we're running at DEBUG, don't change the threshold, as there's + # likely a good reason why we're running at this level. + _global_log.threshold = level + return prev_level + def set_verbosity(v): prev_level = _global_log.threshold if v < 0: @@ -44,4 +65,4 @@ _global_color_map = { FATAL:red_text } -set_verbosity(1) +set_verbosity(INFO) |