mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Only use color log output if stdout is a TTY
This commit is contained in:
@@ -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():
|
||||||
|
log_colors = {
|
||||||
"green": '\033[92m',
|
"green": '\033[92m',
|
||||||
"yellow": '\033[93m',
|
"yellow": '\033[93m',
|
||||||
"red": '\033[91m',
|
"red": '\033[91m',
|
||||||
"reset": '\033[0m',
|
"reset": '\033[0m',
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
|
log_colors = {
|
||||||
|
"green": "",
|
||||||
|
"yellow": "",
|
||||||
|
"red": "",
|
||||||
|
"reset": "",
|
||||||
|
}
|
||||||
|
|
||||||
class TimeFormatter():
|
class TimeFormatter():
|
||||||
def __init__(self, start_time):
|
def __init__(self, start_time):
|
||||||
|
|||||||
Reference in New Issue
Block a user