Changeset 633
- Timestamp:
- 08/27/12 15:17:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/Console.java
r250 r633 3 3 import java.util.Collection; 4 4 import java.util.LinkedHashSet; 5 import java.util.logging.Level; 5 6 6 7 import de.ugoe.cs.util.StringTools; … … 413 414 * <p> 414 415 * Sends a debug message to all observers containing the message that was 415 * passed to this function. 416 * passed to this function. The default log {@link Level} is {@link Level#INFO}. 416 417 * </p> 417 418 * … … 419 420 * message that is send to the observers 420 421 */ 422 @Deprecated 421 423 public static void trace(String traceMsg) { 422 424 for (ITraceListener observer : theInstance.traceListener) { 423 observer.traceMsg(traceMsg); 424 } 425 observer.traceMsg(traceMsg, Level.INFO); 426 } 427 } 428 429 /** 430 * 431 * <p> 432 * Sends a debug message to all trace listeners containing the message that was passed to this function. 433 * </p> 434 * 435 * @param traceMsg message that is send to the trace listener 436 * @param logLevel log level of the message 437 */ 438 public static void trace(String traceMsg, Level logLevel) { 439 for( ITraceListener observer : theInstance.traceListener) { 440 observer.traceMsg(traceMsg, logLevel); 441 } 425 442 } 426 443 … … 429 446 * Sends a debug message to all observers containing the message that was 430 447 * passed to this function and adds an {@link StringTools#ENDLINE} to the 431 * message. 448 * message. The default log {@link Level} is {@link Level#INFO}. 432 449 * </p> 433 450 * … … 435 452 * message that is send to the observers 436 453 */ 454 @Deprecated 437 455 public static void traceln(String traceMsg) { 438 456 for (ITraceListener observer : theInstance.traceListener) { 439 observer.traceMsg(traceMsg + StringTools.ENDLINE); 440 } 457 observer.traceMsg(traceMsg + StringTools.ENDLINE, Level.INFO); 458 } 459 } 460 461 /** 462 * <p> 463 * Sends a debug message to all observers containing the message that was 464 * passed to this function and adds an {@link StringTools#ENDLINE} to the 465 * message. 466 * </p> 467 * 468 * @param traceMsg message that is send to the observers 469 * @param logLevel log levle of the message 470 */ 471 public static void traceln(String traceMsg, Level logLevel) { 472 for( ITraceListener observer : theInstance.traceListener) { 473 observer.traceMsg(traceMsg + StringTools.ENDLINE, logLevel); 474 } 441 475 } 442 476 -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/TextConsole.java
r312 r633 3 3 import java.io.IOException; 4 4 import java.nio.charset.Charset; 5 import java.util.logging.Level; 5 6 6 7 import de.ugoe.cs.util.console.listener.IErrorListener; … … 82 83 */ 83 84 @Override 84 public void traceMsg(String traceMessage ) {85 public void traceMsg(String traceMessage, Level level) { 85 86 if (debugMode) { 86 System.out.print( traceMessage);87 System.out.print("[" + level.toString() + "] " + traceMessage); 87 88 } 88 89 } -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/listener/ITraceListener.java
r223 r633 1 1 package de.ugoe.cs.util.console.listener; 2 3 import java.util.logging.Level; 2 4 3 5 import de.ugoe.cs.util.console.Console; … … 18 20 * 19 21 * @param traceMessage 20 * error message 22 * trace message 23 * @param level 24 * trace level 21 25 */ 22 public void traceMsg(String traceMessage );26 public void traceMsg(String traceMessage, Level level); 23 27 } -
trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/log4j/Log4JLogger.java
r579 r633 1 1 package de.ugoe.cs.quest.log4j; 2 3 import java.util.logging.Level; 2 4 3 5 import org.apache.log4j.Logger; … … 75 77 */ 76 78 @Override 77 public void traceMsg(String traceMessage ) {78 logger.trace(traceMessage);79 public void traceMsg(String traceMessage, Level level) { 80 logger.log(convertToLog4JLevel(level), traceMessage); 79 81 } 80 82 … … 90 92 logger.error(errMessage); 91 93 } 94 95 /** 96 * <p> 97 * Converts the log level described by {@link Level} into a {@link org.apache.log4j.Level}. 98 * </p> 99 * 100 * @param level java.util.logger.Level severity 101 * @return org.apache.log4j.Level severity 102 */ 103 private org.apache.log4j.Level convertToLog4JLevel(Level level) { 104 if(level==Level.OFF) { 105 return org.apache.log4j.Level.OFF; 106 } 107 if(level==Level.SEVERE) { 108 return org.apache.log4j.Level.FATAL; 109 } 110 if(level==Level.WARNING) { 111 return org.apache.log4j.Level.WARN; 112 } 113 if(level==Level.INFO || level==Level.CONFIG) { 114 return org.apache.log4j.Level.INFO; 115 } 116 // remaining levels: FINE, FINER, FINEST, ALL 117 return org.apache.log4j.Level.ALL; 118 } 92 119 } -
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SWTConsole.java
r570 r633 1 1 2 2 package de.ugoe.cs.quest.ui.swt; 3 4 import java.util.logging.Level; 3 5 4 6 import org.eclipse.swt.SWT; … … 38 40 39 41 @Override 40 public void traceMsg(String traceMessage ) {41 appendColored( traceMessage, SWT.COLOR_BLUE);42 public void traceMsg(String traceMessage, Level level) { 43 appendColored("[" + level.toString() + "] " + traceMessage, SWT.COLOR_BLUE); 42 44 } 43 45
Note: See TracChangeset
for help on using the changeset viewer.