Only use color log output if stdout is a TTY

This commit is contained in:
2020-08-27 10:10:32 -05:00
parent 302372847e
commit 7caca9a882

View File

@@ -5,13 +5,22 @@
from datetime import timedelta from datetime import timedelta
import logging import logging
import time import time
import sys
log_colors = { if sys.stdout.isatty():
"green": '\033[92m', log_colors = {
"yellow": '\033[93m', "green": '\033[92m',
"red": '\033[91m', "yellow": '\033[93m',
"reset": '\033[0m', "red": '\033[91m',
} "reset": '\033[0m',
}
else:
log_colors = {
"green": "",
"yellow": "",
"red": "",
"reset": "",
}
class TimeFormatter(): class TimeFormatter():
def __init__(self, start_time): def __init__(self, start_time):