You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ak...@locus.apache.org on 2000/02/13 07:23:58 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java

akv         00/02/12 22:23:58

  Modified:    src/share/org/apache/tomcat/core ContextManager.java
  Log:
  Changed this fellow to use logger.
  
  Revision  Changes    Path
  1.38      +26 -32    jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- ContextManager.java	2000/02/13 01:16:18	1.37
  +++ ContextManager.java	2000/02/13 06:23:58	1.38
  @@ -65,6 +65,7 @@
   import org.apache.tomcat.context.*;
   import org.apache.tomcat.request.*;
   import org.apache.tomcat.util.*;
  +import org.apache.tomcat.logging.*;
   import java.io.*;
   import java.net.*;
   import java.util.*;
  @@ -85,10 +86,8 @@
       /**
        * The string constants for this ContextManager.
        */
  -    private StringManager sm =StringManager.getManager("org.apache.tomcat.core");
  +    private StringManager sm = StringManager.getManager("org.apache.tomcat.core");
   
  -    int debug=0;
  -    
       private Vector requestInterceptors = new Vector();
       private Vector contextInterceptors = new Vector();
       
  @@ -158,9 +157,8 @@
               Context context = getContext((String)enum.nextElement());
               context.init();
   	}
  -	
  -	System.out.println("Init time " + ( System.currentTimeMillis() - time ));
   
  +	log("Time to initialize: "+ (System.currentTimeMillis()-time), Logger.INFORMATION);
   
   	// After all context are configured, we can generate Apache configs
   	org.apache.tomcat.task.ApacheConfig apacheConfig=new  org.apache.tomcat.task.ApacheConfig();
  @@ -242,7 +240,7 @@
   	// IllegalStateException.
   	String path=ctx.getPath();
   	if( getContext( path ) != null ) {
  -	    log("Warning: replacing context for " + path);
  +	    log("Warning: replacing context for " + path, Logger.WARNING);
   	    removeContext(path);
   	}
   
  @@ -255,7 +253,7 @@
   	}
   
   	
  -	if(debug>0) log(" adding " + ctx + " " + ctx.getPath() + " " +  ctx.getDocBase());
  +	log(" adding " + ctx + " " + ctx.getPath() + " " +  ctx.getDocBase(), Logger.INFORMATION);
   
   	contexts.put( path, ctx );
       }
  @@ -329,7 +327,7 @@
        * @param con The new server connector
        */
       public synchronized void addServerConnector( ServerConnector con ) {
  -	if(debug>0) log(" adding connector " + con.getClass().getName());
  +	log(" adding connector " + con.getClass().getName(), Logger.INFORMATION);
   	con.setContextManager( this );
   	connectors.addElement( con );
       }
  @@ -339,7 +337,7 @@
       }
       
       public void addRequestInterceptor( RequestInterceptor ri ) {
  -	if(debug>0) log(" adding request intereptor " + ri.getClass().getName());
  +	log(" adding request intereptor " + ri.getClass().getName(), Logger.INFORMATION);
   	requestInterceptors.addElement( ri );
   	if( ri instanceof ContextInterceptor )
   	    contextInterceptors.addElement( ri );
  @@ -385,6 +383,12 @@
   	return cInterceptors;
       }
   
  +    public void addLogger(Logger logger) {
  +	// Will use this later once I feel more sure what I want to do here.
  +	// -akv
  +    }
  +
  +
       // -------------------- Defaults for all contexts --------------------
       /** The root directory of tomcat
        */
  @@ -442,7 +446,7 @@
        * WorkDir property - where all temporary files will be created
        */ 
       public void setWorkDir( String wd ) {
  -	if( debug>0) log( "set work dir " + wd );
  +	log("set work dir " + wd, Logger.INFORMATION);
   	this.workDir=wd;
       }
   
  @@ -508,9 +512,7 @@
        */
       int processRequest( Request req ) {
   
  -	if(debug>2) log( "ProcessRequest: ");
  -	if(debug>2) log( req.toString() );
  -	if(debug>2) log("");
  +	log("ProcessRequest: "+req.toString(), Logger.DEBUG);
   
   	for( int i=0; i< requestInterceptors.size(); i++ ) {
   	    ((RequestInterceptor)requestInterceptors.elementAt(i)).contextMap( req );
  @@ -519,10 +521,9 @@
   	for( int i=0; i< requestInterceptors.size(); i++ ) {
   	    ((RequestInterceptor)requestInterceptors.elementAt(i)).requestMap( req );
   	}
  +
  +	log("After processing: "+req.toString(), Logger.DEBUG);
   
  -	if(debug>2) log("After processing: ");
  -	if(debug>2) log( req.toString() );
  -	if(debug>2) log("");
   	return 0;
       }
   
  @@ -569,24 +570,17 @@
   	return lr;
       }
   
  -    // -------------------- Utils --------------------
  -    // Debug ( to be replaced with the real thing )
  -    public void setDebug( String  level ) {
  -	setDebug( new Integer( level).intValue());
  -    }
  +    boolean firstLog = true;
  +    Logger cmLog = null;
       
  -    public void setDebug( int level ) {
  -	log( "Setting debug " + level );
  -	debug=level;
  -    }
  -
  -    public int getDebug( ) {
  -	return debug;
  -    }
  +    public final void log(String msg, int level) {
  +	if (firstLog == true) {
  +	    cmLog = Logger.getLogger("CTXMGR_LOG");
  +	    firstLog = false;
  +	}
   
  -    public void log( String msg ) {
  -	System.out.println("CM: " + msg );
  +	if (cmLog != null)
  +	    cmLog.log(msg, level);
       }
  -
       
   }