rootlogger.java

来自「log4j2me 是一个在j2me上使用的log4j风格的源码」· Java 代码 · 共 60 行

JAVA
60
字号

package org.apache.log4j.spi;

import  org.apache.log4j.Category;
import  org.apache.log4j.Priority;
import  org.apache.log4j.helpers.LogLog;


/**
   RootCategory sits at the top of the category hierachy. It is a
   regular category except that it provides several guarantees.

   <p>First, it cannot be assigned a <code>null</code>
   priority. Second, since root category cannot have a parent, the
   {@link #getChainedPriority} method always returns the value of the
   priority field without walking the hierarchy.

   @author Ceki G&uuml;lc&uuml;

 */
final public class RootLogger extends Category {

  /**
     The root category names itself as "root". However, the root
     category cannot be retrieved by name.  
  */
  public
  RootLogger(Priority priority) {
    super("root");
    setPriority(priority);
  }

  
  /**
     Return the assigned priority value without walking the category
     hierarchy.
  */
  final
  public 
  Priority getChainedPriority() {
    return priority;
  }

  /**
     Setting a null value to the priority of the root category may have catastrophic
     results. We prevent this here.

     @since 0.8.3 */
  final  
  public
  void setPriority(Priority priority) {
    if(priority == null) {
      LogLog.error("null priority disallowed", new Throwable());
    }
    else {
      this.priority = priority;
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?