aboutsummaryrefslogtreecommitdiff
path: root/src/util.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-03-05 14:07:52 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-03-05 14:07:52 +0100
commit12922d12c20a9a80f191b37e5571c7563e993ddc (patch)
tree2e1c974505f76aa34f19ab5bb403ff625cf21aa6 /src/util.py
parent8c9af91769619ac04467e63b52e969896e18132c (diff)
downloadallocbench-12922d12c20a9a80f191b37e5571c7563e993ddc.tar.gz
allocbench-12922d12c20a9a80f191b37e5571c7563e993ddc.zip
add new verbosity and colored output
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py
new file mode 100644
index 0000000..4190f82
--- /dev/null
+++ b/src/util.py
@@ -0,0 +1,43 @@
+import colorama
+import sys
+
+import src.globalvars
+
+def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 0:
+ return
+ color = getattr(colorama.Fore, color)
+ print(color, end="", file=file)
+ print(*objects, sep=sep, end=end, file=file)
+ print(colorama.Fore.RESET, end="", file=file, flush=flush)
+
+def print_debug(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 99:
+ return
+ print(*objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_info(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 1:
+ return
+ print(*objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_info0(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 0:
+ return
+ print(*objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_info2(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 2:
+ return
+ print(*objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_status(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ allocbench_msg("GREEN", *objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_warn(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
+ if src.globalvars.verbosity < 1:
+ return
+ allocbench_msg("YELLOW", *objects, sep=sep, end=end, file=file, flush=flush)
+
+def print_error(*objects, sep=' ', end='\n', file=sys.stderr, flush=False):
+ allocbench_msg("RED", *objects, sep=sep, end=end, file=file, flush=flush)