Add WHIPPER_COLOR_LOG env var to color log output
Signed-off-by: Katharina Dröge <kate@commandmc.de>
This commit is contained in:
@@ -14,8 +14,17 @@ except (DistributionNotFound, RequirementParseError):
|
||||
level = logging.INFO
|
||||
if 'WHIPPER_DEBUG' in os.environ:
|
||||
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:
|
||||
logging.basicConfig(filename=os.environ['WHIPPER_LOGFILE'],
|
||||
filemode='w', level=level)
|
||||
log_init_func(filename=os.environ['WHIPPER_LOGFILE'],
|
||||
filemode='w', level=level)
|
||||
else:
|
||||
logging.basicConfig(stream=sys.stderr, level=level)
|
||||
log_init_func(stream=sys.stderr, level=level)
|
||||
|
||||
Reference in New Issue
Block a user