summaryrefslogtreecommitdiffstats
path: root/pyload/Core.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-02 16:14:05 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-02 16:14:05 +0100
commitd2e817bd225d6d1711cbd34e8beb664c46020a5b (patch)
treeed2132fb946ab6c931377298a56e10d4b1557928 /pyload/Core.py
parentchanged ws port to avoid conflicts (diff)
downloadpyload-d2e817bd225d6d1711cbd34e8beb664c46020a5b.tar.xz
colored log on windows
Diffstat (limited to 'pyload/Core.py')
-rw-r--r--pyload/Core.py18
1 files changed, 13 insertions, 5 deletions
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