1 7 8 package net.sourceforge.cvsgrab.util; 9 10 import java.util.Date ; 11 12 import org.apache.commons.logging.impl.SimpleLog; 13 14 21 public class CVSGrabLog extends SimpleLog { 22 23 26 private static final long serialVersionUID = 8484066163771525005L; 27 private String prefix; 28 29 33 public CVSGrabLog(String arg0) { 34 super(arg0); 35 } 36 37 43 protected void log(int type, Object message, Throwable t) { 44 StringBuffer buf = new StringBuffer (); 46 47 if(showDateTime) { 49 buf.append(dateFormatter.format(new Date ())); 50 buf.append(" "); 51 } 52 53 switch(type) { 55 case SimpleLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break; 56 case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break; 57 case SimpleLog.LOG_LEVEL_INFO: break; 58 case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break; 59 case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break; 60 case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break; 61 } 62 63 if( showShortName) { 65 if( prefix==null ) { 66 prefix = logName.substring( logName.lastIndexOf(".") +1) + " - "; 68 prefix = prefix.substring( prefix.lastIndexOf("/") +1) + "-"; 69 } 70 buf.append( prefix ); 71 } else if(showLogName) { 72 buf.append(String.valueOf(logName)).append(" - "); 73 } 74 75 buf.append(String.valueOf(message)); 77 78 if(t != null) { 80 buf.append(" <"); 81 buf.append(t.toString()); 82 buf.append(">"); 83 84 java.io.StringWriter sw= new java.io.StringWriter (1024); 85 java.io.PrintWriter pw= new java.io.PrintWriter (sw); 86 t.printStackTrace(pw); 87 pw.close(); 88 buf.append(sw.toString()); 89 } 90 91 System.err.println(buf.toString()); 93 } 94 95 } 96 | Popular Tags |