1 package hudson.maven; 2 3 import hudson.model.TaskListener; 4 import org.apache.maven.embedder.AbstractMavenEmbedderLogger; 5 import org.apache.maven.embedder.MavenEmbedderLogger; 6 7 import java.io.PrintStream ; 8 import java.util.StringTokenizer ; 9 10 16 final class EmbedderLoggerImpl extends AbstractMavenEmbedderLogger { 17 private final PrintStream logger; 18 19 public EmbedderLoggerImpl(TaskListener listener) { 20 logger = listener.getLogger(); 21 } 22 23 private void print(String message, Throwable throwable, int threshold, String prefix) { 24 if (getThreshold() <= threshold) { 25 StringTokenizer tokens = new StringTokenizer (message,"\n"); 26 while(tokens.hasMoreTokens()) { 27 logger.print(prefix); 28 logger.println(tokens.nextToken()); 29 } 30 31 if (throwable!=null) 32 throwable.printStackTrace(logger); 33 } 34 } 35 36 public void debug(String message, Throwable throwable) { 37 print(message, throwable, LEVEL_DEBUG, "[DEBUG] "); 38 } 39 40 public void info(String message, Throwable throwable) { 41 print(message, throwable, LEVEL_INFO, "[INFO ] "); 42 } 43 44 public void warn(String message, Throwable throwable) { 45 print(message, throwable, LEVEL_WARN, "[WARN ] "); 46 } 47 48 public void error(String message, Throwable throwable) { 49 print(message, throwable, LEVEL_ERROR, "[ERROR] "); 50 } 51 52 public void fatalError(String message, Throwable throwable) { 53 print(message, throwable, LEVEL_FATAL, "[FATAL] "); 54 } 55 } 56 | Popular Tags |