User: user57  
  Date: 02/02/24 02:16:53

  Added:       src/main/org/jboss/logging Logger.java XPriority.java
                        package.html
  Log:
   o moved non-service logging components to common
   o moved Cat* to org.jboss.logging.util
   o renamed TracePriority to XPriority as this class provides the
     ability to hold other extention priorites.
  
  Revision  Changes    Path
  1.1                  jboss-common/src/main/org/jboss/logging/Logger.java
  
  Index: Logger.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  
  package org.jboss.logging;
  
  import org.apache.log4j.Category;
  import org.apache.log4j.Priority;
  
  /** 
   * A custom log4j Category wrapper that adds a trace level priority and only
   * exposes the relevent factory and logging methods.
   *
   * @see #isTraceEnabled
   * @see #trace(Object message)
   * @see #trace(Object, Throwable)
   *
   * @author [EMAIL PROTECTED]
   * @version $Revision: 1.1 $
   */
  public class Logger
  {
     /** The Log4j delegate logger. */
     private Category log;
  
     /** 
      * Creates new JBossCategory with the given category name.
      *
      * @param name    the category name.
      */
     protected Logger(String name)
     {
        log = Category.getInstance(name);
     }
  
     public Category getCategory()
     {
        return log;
     }
  
     /** 
      * Check to see if the TRACE priority is enabled for this category.
      *
      * @return true if a {@link #trace(String)} method invocation would pass
      * the msg to the configured appenders, false otherwise.
      */
     public boolean isTraceEnabled()
     {
        if (log.isEnabledFor(XPriority.TRACE) == false)
           return false;
        return XPriority.TRACE.isGreaterOrEqual(log.getChainedPriority());
     }
  
     /** 
      * Issue a log msg with a priority of TRACE.
      * Invokes log.log(XPriority.TRACE, message);
      */
     public void trace(Object message)
     {
        log.log(XPriority.TRACE, message);
     }
  
     /** 
      * Issue a log msg and throwable with a priority of TRACE.
      * Invokes log.log(XPriority.TRACE, message, t);
      */
     public void trace(Object message, Throwable t)
     {
        log.log(XPriority.TRACE, message, t);
     }
  
     /**
      * Check to see if the TRACE priority is enabled for this category.
      *
      * @return true if a {@link #trace(String)} method invocation would pass
      * the msg to the configured appenders, false otherwise.
      */
     public boolean isDebugEnabled()
     {
        Priority p = Priority.DEBUG;
        if (log.isEnabledFor(p) == false)
           return false;
        return p.isGreaterOrEqual(log.getChainedPriority());
     }
  
     /** 
      * Issue a log msg with a priority of DEBUG.
      * Invokes log.log(Priority.DEBUG, message);
      */
     public void debug(Object message)
     {
        log.log(Priority.DEBUG, message);
     }
  
     /** 
      * Issue a log msg and throwable with a priority of DEBUG.
      * Invokes log.log(Priority.DEBUG, message, t);
      */
     public void debug(Object message, Throwable t)
     {
        log.log(Priority.DEBUG, message, t);
     }
  
     /** 
      * Check to see if the INFO priority is enabled for this category.
      *
      * @return true if a {@link #info(String)} method invocation would pass
      * the msg to the configured appenders, false otherwise.
      */
     public boolean isInfoEnabled()
     {
        Priority p = Priority.INFO;
        if (log.isEnabledFor(p) == false)
           return false;
        return p.isGreaterOrEqual(log.getChainedPriority());
     }
  
     /** 
      * Issue a log msg with a priority of INFO.
      * Invokes log.log(Priority.INFO, message);
      */
     public void info(Object message)
     {
        log.log(Priority.INFO, message);
     }
  
     /**
      * Issue a log msg and throwable with a priority of INFO.
      * Invokes log.log(Priority.INFO, message, t);
      */
     public void info(Object message, Throwable t)
     {
        log.log(Priority.INFO, message, t);
     }
  
     /** 
      * Issue a log msg with a priority of WARN.
      * Invokes log.log(Priority.WARN, message);
      */
     public void warn(Object message)
     {
        log.log(Priority.WARN, message);
     }
  
     /** 
      * Issue a log msg and throwable with a priority of WARN.
      * Invokes log.log(Priority.WARN, message, t);
      */
     public void warn(Object message, Throwable t)
     {
        log.log(Priority.WARN, message, t);
     }
  
     /** 
      * Issue a log msg with a priority of ERROR.
      * Invokes log.log(Priority.ERROR, message);
      */
     public void error(Object message)
     {
        log.log(Priority.ERROR, message);
     }
  
     /** 
      * Issue a log msg and throwable with a priority of ERROR.
      * Invokes log.log(Priority.ERROR, message, t);
      */
     public void error(Object message, Throwable t)
     {
        log.log(Priority.ERROR, message, t);
     }
  
     /** 
      * Issue a log msg with a priority of FATAL.
      * Invokes log.log(Priority.FATAL, message);
      */
     public void fatal(Object message)
     {
        log.log(Priority.FATAL, message);
     }
  
     /** 
      * Issue a log msg and throwable with a priority of FATAL.
      * Invokes log.log(Priority.FATAL, message, t);
      */
     public void fatal(Object message, Throwable t)
     {
        log.log(Priority.FATAL, message, t);
     }
  
     /** 
      * Issue a log msg with the given priority.
      * Invokes log.log(p, message);
      */
     public void log(Priority p, Object message)
     {
        log.log(p, message);
     }
  
     /** 
      * Issue a log msg with the given priority.
      * Invokes log.log(p, message, t);
      */
     public void log(Priority p, Object message, Throwable t)
     {
        log.log(p, message, t);
     }
  
  
     /////////////////////////////////////////////////////////////////////////
     //                            Factory Methods                          //
     /////////////////////////////////////////////////////////////////////////
  
     /** 
      * Create a Logger instance given the category name.
      *
      * @param name    the category name
      */
     public static Logger getLogger(String name)
     {
        Logger logger = new Logger(name);
        return logger;
     }
  
     /** 
      * Create a Logger instance given the category class. This simply
      * calls create(clazz.getName()).
      *
      * @param clazz    the Class whose name will be used as the category name
      */
     public static Logger getLogger(Class clazz)
     {
        Logger logger = new Logger(clazz.getName());
        return logger;
     }
  }
  
  
  
  1.1                  jboss-common/src/main/org/jboss/logging/XPriority.java
  
  Index: XPriority.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  
  package org.jboss.logging;
  
  import org.apache.log4j.Priority;
  
  /** 
   * Provides custom extention priorites for use with the
   * Log4j logging framework.
   *
   * Adds a trace priority that is below the standard log4j DEBUG priority.
   * This is a custom priority that is 100 below the Priority.DEBUG_INT and
   * represents a lower priority useful for logging events that should only
   * be displayed when deep debugging is required.
   *
   * @see org.apache.log4j.Category
   * @see org.apache.log4j.Priority
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
   * @version $Revision: 1.1 $
   */
  public class XPriority 
     extends Priority
  {
     /** The integer representation of the priority, (Priority.DEBUG_INT - 100) */
     public static final int TRACE_INT = Priority.DEBUG_INT - 100;
  
     /** The string name of the trace priority. */
     public static String TRACE_STR = "TRACE";
     
     /** The TRACE priority object singleton */
     public static final XPriority TRACE = new XPriority(TRACE_INT, TRACE_STR, 7);
  
     /**
      * Construct a <tt>XPriority</tt>.
      */
     protected XPriority(int level, String strLevel, int syslogEquiv)
     {
        super(level, strLevel, syslogEquiv);
     }
     
  
     /////////////////////////////////////////////////////////////////////////
     //                            Factory Methods                          //
     /////////////////////////////////////////////////////////////////////////
  
     /** 
      * Convert an integer passed as argument to a priority. If the conversion
      * fails, then this method returns the specified default.
      * @return the Priority object for name if one exists, defaultPriority otherwize.
      */
     public static Priority toPriority(String name, Priority defaultPriority)
     {
        if (name == null)
           return defaultPriority;
  
        String upper = name.toUpperCase();
        if (upper.equals(TRACE_STR)) {
           return TRACE;
        }
  
        return Priority.toPriority(name, defaultPriority);
     }
  
     /** 
      * Convert an integer passed as argument to a priority.
      * 
      * @return the Priority object for name if one exists
      */
     public static Priority toPriority(String name)
     {
        return toPriority(name, TRACE);
     }
     
     /** 
      * Convert an integer passed as argument to a priority. If the conversion
      * fails, then this method returns the specified default.
      * @return the Priority object for i if one exists, defaultPriority otherwize.
      */
     public static Priority toPriority(int i, Priority defaultPriority)
     {
        Priority p;
        if (i == TRACE_INT)
           p = TRACE;
        else
           p = Priority.toPriority(i);
        return p;
     }
  }
  
  
  
  1.1                  jboss-common/src/main/org/jboss/logging/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
    <head>
      <!-- $Id: package.html,v 1.1 2002/02/24 10:16:52 user57 Exp $ -->
      <!--
  
      JBoss: The OpenSource J2EE WebOS 
  
      Distributable under LGPL license.
      See terms of license at gnu.org.
  
      -->
    </head>
  
    <body bgcolor="white">
      <p>Common logging infrastructure.
  
      <h2>Package Specification</h2>
      <ul>
        <li><a href="javascript: alert('not available')">Not Available</a>
      </ul>
        
      <h2>Related Documentation</h2>
      <ul>
        <li><a href="javascript: alert('not available')">Not Available</a>
      </ul>
  
      <h2>Package Status</h2>
      <ul>
        <li><font color="green"><b>STABLE</b></font>
      </ul>
  
      <h2>Todo</h2>
      <ul>
        <li>???
      </ul>
  
      <!-- Put @see and @since tags down here. -->
  
    </body>
  </html>
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to