1 2 3 27 package org.apache.tomcat.util.log; 28 29 import java.io.*; 30 import java.lang.reflect.*; 31 import java.util.*; 32 33 34 43 public class LogManager { 44 45 static LogHandler defaultChannel=new CommonLogHandler(); 47 48 protected Hashtable loggers=new Hashtable(); 49 protected Hashtable channels=new Hashtable(); 50 51 public Hashtable getLoggers() { 52 return loggers; 53 } 54 55 public Hashtable getChannels() { 56 return channels; 57 } 58 59 public static void setDefault( LogHandler l ) { 60 if( defaultChannel==null) 61 defaultChannel=l; 62 } 63 64 public void addChannel( String name, LogHandler logH ) { 65 if(name==null) name=""; 66 67 channels.put( name, logH ); 68 Enumeration enumeration=loggers.keys(); 69 while( enumeration.hasMoreElements() ) { 70 String k=(String )enumeration.nextElement(); 71 Log l=(Log)loggers.get( k ); 72 if( name.equals( l.getChannel( this ) )) { 73 l.setProxy( this, logH ); 74 } 75 } 76 } 77 78 80 public Log getLog( String channel, String prefix, 81 Object owner ) { 82 if( prefix==null && owner!=null ) { 83 String cname = owner.getClass().getName(); 84 prefix = cname.substring( cname.lastIndexOf(".") +1); 85 } 86 87 LogHandler proxy=(LogHandler)channels.get(channel); 88 if( proxy==null ) proxy=defaultChannel; 89 90 Log log=new Log( channel, prefix, proxy, owner ); 92 loggers.put( channel + ":" + prefix, log ); 93 if( dL > 0 ) 94 System.out.println("getLog facade " + channel + ":" + prefix); 95 return log; 96 } 97 98 private static int dL=0; 99 100 } 101 | Popular Tags |