JAL-3071 IdPanel.ScrollThread for JalviewJS, Javadoc
[jalview.git] / srcjar_unused / org / apache / log4j / Logger.java
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.apache.log4j;
19
20 import org.apache.log4j.spi.LoggerFactory;
21
22
23 /**
24   This is the central class in the log4j package. Most logging
25   operations, except configuration, are done through this class.
26
27   @since log4j 1.2
28
29   @author Ceki Gülcü */
30 public class Logger extends Category {
31
32   /**
33      The fully qualified name of the Logger class. See also the
34      getFQCN method. */
35   private static final String FQCN = Logger.class.getName();
36
37
38   protected
39   Logger(String name) {
40     super(name);
41   }
42
43   /**
44    * Retrieve a logger named according to the value of the
45    * <code>name</code> parameter. If the named logger already exists,
46    * then the existing instance will be returned. Otherwise, a new
47    * instance is created.  
48    *
49    * <p>By default, loggers do not have a set level but inherit it
50    * from their neareast ancestor with a set level. This is one of the
51    * central features of log4j.
52    *
53    * @param name The name of the logger to retrieve.  
54   */
55   static
56   public
57   Logger getLogger(String name) {
58     return LogManager.getLogger(name);
59   }
60
61   /**
62    * Shorthand for <code>getLogger(clazz.getName())</code>.
63    *
64    * @param clazz The name of <code>clazz</code> will be used as the
65    * name of the logger to retrieve.  See {@link #getLogger(String)}
66    * for more detailed information.
67    */
68   static
69   public
70   Logger getLogger(Class clazz) {
71     return LogManager.getLogger(clazz.getName());
72   }
73
74
75   /**
76    * Return the root logger for the current logger repository.
77    * <p>
78    * The {@link #getName Logger.getName()} method for the root logger always returns
79    * string value: "root". However, calling
80    * <code>Logger.getLogger("root")</code> does not retrieve the root
81    * logger but a logger just under root named "root".
82    * <p>
83    * In other words, calling this method is the only way to retrieve the 
84    * root logger.
85    */
86   public
87   static
88   Logger getRootLogger() {
89     return LogManager.getRootLogger();
90   }
91
92   /**
93      Like {@link #getLogger(String)} except that the type of logger
94      instantiated depends on the type returned by the {@link
95      LoggerFactory#makeNewLoggerInstance} method of the
96      <code>factory</code> parameter.
97
98      <p>This method is intended to be used by sub-classes.
99
100      @param name The name of the logger to retrieve.
101
102      @param factory A {@link LoggerFactory} implementation that will
103      actually create a new Instance.
104
105      @since 0.8.5 */
106   public
107   static
108   Logger getLogger(String name, LoggerFactory factory) {
109     return LogManager.getLogger(name, factory);
110   }
111
112     /**
113      * Log a message object with the {@link org.apache.log4j.Level#TRACE TRACE} level.
114      *
115      * @param message the message object to log.
116      * @see #debug(Object) for an explanation of the logic applied.
117      * @since 1.2.12
118      */
119     public void trace(Object message) {
120       if (repository.isDisabled(Level.TRACE_INT)) {
121         return;
122       }
123
124       if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
125         forcedLog(FQCN, Level.TRACE, message, null);
126       }
127     }
128
129     /**
130      * Log a message object with the <code>TRACE</code> level including the
131      * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
132      *
133      * <p>
134      * See {@link #debug(Object)} form for more detailed information.
135      * </p>
136      *
137      * @param message the message object to log.
138      * @param t the exception to log, including its stack trace.
139      * @since 1.2.12
140      */
141     public void trace(Object message, Throwable t) {
142       if (repository.isDisabled(Level.TRACE_INT)) {
143         return;
144       }
145
146       if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
147         forcedLog(FQCN, Level.TRACE, message, t);
148       }
149     }
150
151     /**
152      * Check whether this category is enabled for the TRACE  Level.
153      * @since 1.2.12
154      *
155      * @return boolean - <code>true</code> if this category is enabled for level
156      *         TRACE, <code>false</code> otherwise.
157      */
158     public boolean isTraceEnabled() {
159         if (repository.isDisabled(Level.TRACE_INT)) {
160             return false;
161           }
162
163           return Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel());
164     }
165
166 }