diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 17:26:31 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 17:26:31 +0000 |
commit | 8e2654541c6eae0f308908f501cccbc86b2f9101 (patch) | |
tree | bfcfe3b282c8fb659832bf86a841ce76852094ad /numpy/distutils/log.py | |
parent | ddaed649c23bbd0ad36cdafdfe9cd92397ce69e3 (diff) | |
download | numpy-8e2654541c6eae0f308908f501cccbc86b2f9101.tar.gz |
Moved scipy directory to numpy
Diffstat (limited to 'numpy/distutils/log.py')
-rw-r--r-- | numpy/distutils/log.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/numpy/distutils/log.py b/numpy/distutils/log.py new file mode 100644 index 000000000..6d72f9222 --- /dev/null +++ b/numpy/distutils/log.py @@ -0,0 +1,47 @@ +# Colored log, requires Python 2.3 or up. + +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 + + +def _fix_args(args,flag=1): + if type(args) is type(''): + return args.replace('%','%%') + if flag and type(args) is type(()): + return tuple([_fix_args(a,flag=0) for a in args]) + return args + +class Log(old_Log): + def _log(self, level, msg, args): + if level>= self.threshold: + if args: + print _global_color_map[level](msg % _fix_args(args)) + else: + print _global_color_map[level](msg) + sys.stdout.flush() +_global_log.__class__ = Log + +def set_verbosity(v): + prev_level = _global_log.threshold + if v<0: + set_threshold(ERROR) + elif v == 0: + set_threshold(WARN) + elif v == 1: + set_threshold(INFO) + elif v >= 2: + set_threshold(DEBUG) + return {FATAL:-2,ERROR:-1,WARN:0,INFO:1,DEBUG:2}.get(prev_level,1) + +_global_color_map = { + DEBUG:cyan_text, + INFO:yellow_text, + WARN:red_text, + ERROR:red_text, + FATAL:red_text +} + +set_verbosity(1) |