User: norbert 
  Date: 00/06/19 15:09:39

  Modified:    src/java/org/spydermq Log.java
  Log:
  Change the log type
  
  Revision  Changes    Path
  1.8       +32 -3     spyderMQ/src/java/org/spydermq/Log.java
  
  Index: Log.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spydermq/Log.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Log.java  2000/06/19 21:51:57     1.7
  +++ Log.java  2000/06/19 22:09:39     1.8
  @@ -6,22 +6,48 @@
    */
   package org.spydermq;
   
  +import java.io.InputStream;
  +import java.util.Properties;
  +
   /**
    * This is a very basic log system,
    * the only functionnality that we need is to be able to shut down the log. 
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.7 $
  + *   @version $Revision: 1.8 $
    */
  +
   public class Log
   {
  +     
  +     final static int NOT_SET                = 0;
        final static int LOG_EVERYTHING = 1;
        final static int LOG_NOTICE             = 2;
        final static int LOG_ERRORS             = 3;
  +     
  +     static int logType = NOT_SET;           
        
  -     //Change this line change the verbosity level
  -     final static int logType = LOG_EVERYTHING;
  +     private static void getLevel()
  +     {
  +             try {
  +             
  +                     InputStream in = 
Thread.currentThread().getContextClassLoader().getResource("spyderMQ.properties").openStream();
  +                     Properties cfg=new Properties();
  +                     cfg.load(in);
  +                     in.close();
  +
  +                     String logLevel = (String)cfg.get("LogLevel" );
  +                     
  +                     if (logLevel.equals("LOG_EVERYTHING")) logType=LOG_EVERYTHING;
  +                     else if (logLevel.equals("LOG_NOTICE")) logType=LOG_NOTICE;
  +                     else logType=LOG_ERRORS;
  +                     
  +             } catch (Exception e) {
  +                     logType=LOG_ERRORS;
  +             }
  +     
  +     }
        
        private static void print(Object obj)
        {
  @@ -34,6 +60,7 @@
        
        public static void log(Object obj)
        {
  +             if (logType == NOT_SET) getLevel();
                if (logType>LOG_EVERYTHING) return;
                print(obj);
        }
  @@ -42,6 +69,7 @@
        
        public static void notice(Object obj)
        {
  +             if (logType == NOT_SET) getLevel();
                if (logType>LOG_NOTICE) return;
                print(obj);
        }
  @@ -50,6 +78,7 @@
        
        public static void error(Object obj)
        {
  +             if (logType == NOT_SET) getLevel();
                print(obj);
        }
        
  
  
  

Reply via email to