Add WHIPPER_COLOR_LOG env var to color log output
Signed-off-by: Katharina Dröge <kate@commandmc.de>
This commit is contained in:
3
setup.py
3
setup.py
@@ -17,7 +17,8 @@ setup(
|
|||||||
sources=['src/accuraterip-checksum.c'])
|
sources=['src/accuraterip-checksum.c'])
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'cover_art': ["pillow"]
|
'cover_art': ["pillow"],
|
||||||
|
'color_log': ["coloredlogs"]
|
||||||
},
|
},
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|||||||
@@ -14,8 +14,17 @@ except (DistributionNotFound, RequirementParseError):
|
|||||||
level = logging.INFO
|
level = logging.INFO
|
||||||
if 'WHIPPER_DEBUG' in os.environ:
|
if 'WHIPPER_DEBUG' in os.environ:
|
||||||
level = os.environ['WHIPPER_DEBUG'].upper()
|
level = os.environ['WHIPPER_DEBUG'].upper()
|
||||||
|
|
||||||
|
log_init_func = logging.basicConfig
|
||||||
|
if 'WHIPPER_COLOR_LOG' in os.environ:
|
||||||
|
import coloredlogs
|
||||||
|
def init_coloredlogs(**kwargs):
|
||||||
|
# coloredlogs comes with its own log format, we don't want to use that
|
||||||
|
coloredlogs.install(fmt=logging.BASIC_FORMAT, **kwargs)
|
||||||
|
log_init_func = init_coloredlogs
|
||||||
|
|
||||||
if 'WHIPPER_LOGFILE' in os.environ:
|
if 'WHIPPER_LOGFILE' in os.environ:
|
||||||
logging.basicConfig(filename=os.environ['WHIPPER_LOGFILE'],
|
log_init_func(filename=os.environ['WHIPPER_LOGFILE'],
|
||||||
filemode='w', level=level)
|
filemode='w', level=level)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(stream=sys.stderr, level=level)
|
log_init_func(stream=sys.stderr, level=level)
|
||||||
|
|||||||
Reference in New Issue
Block a user