From 08839e144cb77f7f6e7193867ab66c59775b0b8b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 14 Nov 2013 02:11:57 +0100 Subject: Coloured logging --- pyload/Core.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pyload/Core.py') diff --git a/pyload/Core.py b/pyload/Core.py index 324494500..96421d862 100644 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -59,6 +59,8 @@ from utils.fs import free_space, exists, makedirs, join, chmod from codecs import getwriter +from utils.colorlog import ColoredFormatter + # test runner overwrites sys.stdout if hasattr(sys.stdout, "encoding"): enc = get_console_encoding(sys.stdout.encoding) else: enc = "utf8" @@ -517,7 +519,17 @@ class Core(object): if not tfrm: tfrm = "%Y-%m-%d %H:%M:%S" - frm = logging.Formatter("%(asctime)s %(levelname)-8s %(message)s", tfrm) + frm = ColoredFormatter( + format="%(asctime)s %(log_color)s%(bold)s%(black)s %(levelname)+8s %(reset)s %(message)s", + datefmt=tfrm, + log_colors={ + 'DEBUG': 'bg_cyan', + 'INFO': 'bg_green', + 'WARNING': 'bg_yellow', + 'ERROR': 'bg_red', + 'CRITICAL': 'bg_purple', + } + ) console.setFormatter(frm) self.log = logging.getLogger("log") # setable in config -- cgit v1.2.3