Changeset 674 for trunk/java-utils
- Timestamp:
- 08/28/12 16:42:22 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/TextConsole.java
r633 r674 21 21 public class TextConsole implements IOutputListener, IErrorListener, 22 22 ITraceListener, IExceptionListener { 23 23 24 24 /** 25 * <p> 26 * In the debug mode, trace messages will be printed. 27 * </p> 25 * <p>Defines the trace level used by this console.</p> 28 26 */ 29 private boolean debugMode = true; 27 private Level traceLevel; 28 29 /** 30 * <p> 31 * Creates a new text console and automatically registers it as observer. The trace level is {@link Level#WARNING}. 32 * </p> 33 */ 34 public TextConsole() { 35 this(Level.WARNING); 36 } 30 37 31 38 /** … … 33 40 * Creates a new text console and automatically registers it as observer. 34 41 * </p> 42 * @param traceLevel trace level used by this text console 35 43 */ 36 public TextConsole( ) {44 public TextConsole(Level traceLevel) { 37 45 Console.getInstance().registerOutputListener(this); 38 46 Console.getInstance().registerErrorListener(this); 39 47 Console.getInstance().registerTraceListener(this); 40 48 Console.getInstance().registerExceptionListener(this); 49 this.traceLevel = traceLevel; 41 50 } 42 51 … … 84 93 @Override 85 94 public void traceMsg(String traceMessage, Level level) { 86 if ( debugMode) {95 if (level.intValue()>=traceLevel.intValue()) { 87 96 System.out.print("[" + level.toString() + "] " + traceMessage); 88 97 } … … 95 104 * {@code stdin}. 96 105 * </p> 97 *98 * @param debugMode99 * true, if the application is to run in debug mode, i.e. trace100 * messages will be printed101 106 */ 102 public void run(boolean debugMode) { 103 this.debugMode = debugMode; 107 public void run() { 104 108 CommandExecuter exec = CommandExecuter.getInstance(); 105 109 while (true) { … … 136 140 } 137 141 138 /**139 * <p>140 * Configures if the debug mode of the text console is enabled.141 * </p>142 *143 * @param debug144 * if true, debug mode is enabled.145 */146 public void setDebug(boolean debug) {147 debugMode = debug;148 }149 150 142 }
Note: See TracChangeset
for help on using the changeset viewer.