1 19 20 package common.log; 21 22 import common.Logger; 23 24 27 public class SimpleLogger extends Logger 28 { 29 32 private boolean suppressWarnings; 33 34 37 public SimpleLogger() 38 { 39 suppressWarnings = false; 40 } 41 42 45 public void debug(Object message) 46 { 47 if (!suppressWarnings) 48 { 49 System.out.print("Debug: "); 50 System.out.println(message); 51 } 52 } 53 54 57 public void debug(Object message, Throwable t) 58 { 59 if (!suppressWarnings) 60 { 61 System.out.print("Debug: "); 62 System.out.println(message); 63 t.printStackTrace(); 64 } 65 } 66 67 70 public void error(Object message) 71 { 72 System.err.print("Error: "); 73 System.err.println(message); 74 } 75 76 79 public void error(Object message, Throwable t) 80 { 81 System.err.print("Error: "); 82 System.err.println(message); 83 t.printStackTrace(); 84 } 85 86 89 public void fatal(Object message) 90 { 91 System.err.print("Fatal: "); 92 System.err.println(message); 93 } 94 95 98 public void fatal(Object message, Throwable t) 99 { 100 System.err.print("Fatal: "); 101 System.err.println(message); 102 t.printStackTrace(); 103 } 104 105 108 public void info(Object message) 109 { 110 if (!suppressWarnings) 111 { 112 System.out.println(message); 113 } 114 } 115 116 119 120 public void info(Object message, Throwable t) 121 { 122 if (!suppressWarnings) 123 { 124 System.out.println(message); 125 t.printStackTrace(); 126 } 127 } 128 129 132 public void warn(Object message) 133 { 134 if (!suppressWarnings) 135 { 136 System.err.print("Warning: "); 137 System.err.println(message); 138 } 139 } 140 141 144 public void warn(Object message, Throwable t) 145 { 146 if (!suppressWarnings) 147 { 148 System.err.print("Warning: "); 149 System.err.println(message); 150 t.printStackTrace(); 151 } 152 } 153 154 157 protected Logger getLoggerImpl(Class c) 158 { 159 return this; 160 } 161 162 172 public void setSuppressWarnings(boolean w) 173 { 174 suppressWarnings = w; 175 } 176 } 177 | Popular Tags |