1 2 3 27 package org.apache.tomcat.util.log; 28 29 import org.apache.tomcat.util.log.*; 30 import java.io.Writer ; 31 import java.io.PrintWriter ; 32 import java.io.FileWriter ; 33 import java.io.File ; 34 import java.io.OutputStreamWriter ; 35 import java.io.IOException ; 36 import java.io.StringWriter ; 37 38 import java.util.*; 39 40 import com.sun.org.apache.commons.logging.*; 41 42 47 public class CommonLogHandler extends LogHandler { 48 49 private Hashtable loggers=new Hashtable(); 50 51 61 public void log(String prefix, String msg, Throwable t, 62 int verbosityLevel) 63 { 64 if( prefix==null ) prefix="tomcat"; 65 66 com.sun.org.apache.commons.logging.Log l=(com.sun.org.apache.commons.logging.Log)loggers.get( prefix ); 67 if( l==null ) { 68 l=LogFactory.getLog( prefix ); 69 loggers.put( prefix, l ); 70 } 71 72 if( verbosityLevel > this.level ) return; 73 74 if( t==null ) { 75 if( verbosityLevel == Log.FATAL ) 76 l.fatal(msg); 77 else if( verbosityLevel == Log.ERROR ) 78 l.error( msg ); 79 else if( verbosityLevel == Log.WARNING ) 80 l.warn( msg ); 81 else if( verbosityLevel == Log.INFORMATION) 82 l.info( msg ); 83 else if( verbosityLevel == Log.DEBUG ) 84 l.debug( msg ); 85 } else { 86 if( verbosityLevel == Log.FATAL ) 87 l.fatal(msg, t); 88 else if( verbosityLevel == Log.ERROR ) 89 l.error( msg, t ); 90 else if( verbosityLevel == Log.WARNING ) 91 l.warn( msg, t ); 92 else if( verbosityLevel == Log.INFORMATION) 93 l.info( msg, t ); 94 else if( verbosityLevel == Log.DEBUG ) 95 l.debug( msg, t ); 96 } 97 } 98 99 102 public void flush() { 103 } 105 106 109 public synchronized void close() { 110 } 112 113 } 114 | Popular Tags |