[Pkg-bitcoin-commits] [python-quamash] 55/78: use colorlog if available

Jonas Smedegaard dr at jones.dk
Tue Dec 19 01:19:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.6.0_dfsg-1
in repository python-quamash.

commit 7d7ba1c07454d13906f92158ddd47f1761fff234
Author: Mark Thomas West Harviston <mark.harviston at gmail.com>
Date:   Sun Nov 19 17:19:37 2017 -0800

    use colorlog if available
---
 conftest.py | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/conftest.py b/conftest.py
index e34e139..22d3648 100644
--- a/conftest.py
+++ b/conftest.py
@@ -3,8 +3,32 @@ import os.path
 import logging
 from pytest import fixture
 sys.path.insert(0, os.path.dirname(__file__))
-logging.basicConfig(
-	level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
+
+try:
+	import colorlog
+	handler = colorlog.StreamHandler()
+	
+	formatter = colorlog.ColoredFormatter(
+		"%(log_color)s%(levelname)-8s%(reset)s %(name)-32s %(message)s",
+		datefmt=None,
+		reset=True,
+		log_colors={
+			'DEBUG':    'cyan',
+			'INFO':     'green',
+			'WARNING':  'yellow',
+			'ERROR':    'red',
+			'CRITICAL': 'red,bg_white',
+		},
+		secondary_log_colors={},
+		style='%'
+	)
+	handler.setFormatter(formatter)
+	logger = colorlog.getLogger()
+	logger.addHandler(handler)
+	logger.setLevel(logging.DEBUG)
+except ImportError:
+	logging.basicConfig(
+		level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
 
 if os.name == 'nt':
 	collect_ignore = ['quamash/_unix.py']

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git



More information about the Pkg-bitcoin-commits mailing list