aboutsummaryrefslogtreecommitdiff
path: root/src/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util.py b/src/util.py
index 7265a6b..b7d4541 100644
--- a/src/util.py
+++ b/src/util.py
@@ -5,14 +5,20 @@ import src.globalvars
def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout):
if src.globalvars.verbosity < 0:
return
+
color = {"YELLOW": "\x1b[33m",
"GREEN": "\x1b[32m",
"RED": "\x1b[31m"}[color]
- print(color, end="", file=file, flush=True)
+ is_atty = sys.stdout.isatty()
+ if is_atty:
+ print(color, end="", file=file, flush=True)
+
print(*objects, sep=sep, end=end, file=file)
- print("\x1b[0m", end="", file=file, flush=True)
+
+ if is_atty:
+ print("\x1b[0m", end="", file=file, flush=True)
def print_debug(*objects, sep=' ', end='\n', file=sys.stdout):
if src.globalvars.verbosity < 99: