001 package escjava.vcGeneration;
002
003 public class TDisplay {
004
005 private static boolean err;
006
007 private static boolean warn;
008
009 private static boolean info;
010
011 private static boolean colors;
012
013 static/*@ non_null @*/String errPrompt;
014
015 static/*@ non_null @*/String warnPrompt;
016
017 static/*@ non_null @*/String infoPrompt;
018
019 static public void init(boolean err, boolean warn, boolean info, boolean colors) {
020
021 TDisplay.err = err;
022 TDisplay.warn = warn;
023 TDisplay.info = info;
024 TDisplay.colors = colors;
025
026 if (!colors) {
027 TDisplay.errPrompt = "Err ";
028 TDisplay.warnPrompt = "Warning ";
029 } else {
030 TDisplay.errPrompt = "\033[31m>\033[0;m ";
031 TDisplay.warnPrompt = "\033[33m>\033[0;m ";
032 }
033
034 }
035
036 public static void err(/*@ non_null @*/Object o, /*@ non_null @*/String method, String err) {
037
038 if (TDisplay.err) {
039 System.err.println(errPrompt + o.getClass().getName() + "."
040 + method);
041 System.err.println(" " + err);
042 }
043 }
044
045 public static void warn(/*@ non_null @*/Object o, /*@ non_null @*/String method, String warn) {
046
047 if (TDisplay.warn) {
048 System.err.println(warnPrompt + o.getClass().getName() + "."
049 + method);
050 System.err.println(" " + warn);
051 }
052 }
053
054 public static void info(/*@ non_null @*/Object o, /*@ non_null @*/String method, String info) {
055
056 if (TDisplay.info) {
057 System.err.println("[" + o.getClass().getName() + "." + method
058 + "]");
059 System.err.println("[" + info + "]");
060 }
061
062 }
063
064 public static void err(/*@ non_null @*/String o, /*@ non_null @*/String method, String err) {
065
066 if (TDisplay.err) {
067 System.err.println(errPrompt + o + "." + method);
068 System.err.println(" " + err);
069 }
070
071 }
072
073 public static void warn(/*@ non_null @*/String o, /*@ non_null @*/String method, String warn) {
074
075 if (TDisplay.warn) {
076 System.err.println(warnPrompt + o + "." + method);
077 System.err.println(" " + warn);
078 }
079
080 }
081
082 public static void info(/*@ non_null @*/String o, /*@ non_null @*/String method, String info) {
083
084 if (TDisplay.info) {
085 System.err.println("[" + o + "." + method + "]");
086 System.err.println("[" + info + "]");
087 }
088
089 }
090
091 }