From 70530c0767df84b49675cf12b69e0ae7e9289ed1 Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 4 Jul 2012 09:32:33 +0200 Subject: [PATCH] colors for debugging --- debug.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/debug.py b/debug.py index 4b96b592..499e70da 100644 --- a/debug.py +++ b/debug.py @@ -1,4 +1,12 @@ import inspect +try: + from colorama import Fore, init + init() +except ImportError: + class Fore(object): + RED = '' + GREEN = '' + RESET = '' NOTICE = object() WARNING = object() @@ -25,8 +33,8 @@ def error(*args): def print_to_stdout(level, *args): """ The default debug function """ - print(('dbg: ' if level == NOTICE else 'warning: ') + - ', '.join(str(a) for a in args)) + msg = (Fore.GREEN + 'dbg: ' if level == NOTICE else Fore.RED + 'warning: ') + print(msg + ', '.join(str(a) for a in args) + Fore.RESET) debug_function = None