colors for debugging

This commit is contained in:
David Halter
2012-07-04 09:32:33 +02:00
parent d7d4e36558
commit 70530c0767

View File

@@ -1,4 +1,12 @@
import inspect import inspect
try:
from colorama import Fore, init
init()
except ImportError:
class Fore(object):
RED = ''
GREEN = ''
RESET = ''
NOTICE = object() NOTICE = object()
WARNING = object() WARNING = object()
@@ -25,8 +33,8 @@ def error(*args):
def print_to_stdout(level, *args): def print_to_stdout(level, *args):
""" The default debug function """ """ The default debug function """
print(('dbg: ' if level == NOTICE else 'warning: ') + msg = (Fore.GREEN + 'dbg: ' if level == NOTICE else Fore.RED + 'warning: ')
', '.join(str(a) for a in args)) print(msg + ', '.join(str(a) for a in args) + Fore.RESET)
debug_function = None debug_function = None