From d2e817bd225d6d1711cbd34e8beb664c46020a5b Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 2 Jan 2014 16:14:05 +0100 Subject: colored log on windows --- pyload/Core.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'pyload/Core.py') diff --git a/pyload/Core.py b/pyload/Core.py index 2a08b37f7..4a9c51379 100644 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -507,9 +507,10 @@ class Core(object): # file handler formatter fhfmt = "%(asctime)s %(levelname)-8s %(message)s" fh_frm = logging.Formatter(fhfmt, datefmt) + console_frm = fh_frm # console formatter - if self.config['log']['console_color'] and os.name != "nt": + if self.config['log']['console_color']: from lib.colorlog import ColoredFormatter if self.config['log']['color_theme'] == "full": @@ -530,11 +531,18 @@ class Core(object): 'CRITICAL': 'purple', } - console_frm = ColoredFormatter(cfmt, datefmt, clr) - else: - console_frm = fh_frm + color = True + if os.name == "nt": + try: + import colorama + colorama.init() + except: + color = False + print "Install 'colorama' to use the colored log on windows" + + if color: console_frm = ColoredFormatter(cfmt, datefmt, clr) - #: set console formatter + # set console formatter console.setFormatter(console_frm) self.log = logging.getLogger("log") # setable in config -- cgit v1.2.3