• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2004-2011 QOS.ch
3  * All rights reserved.
4  *
5  * Permission is hereby granted, free  of charge, to any person obtaining
6  * a  copy  of this  software  and  associated  documentation files  (the
7  * "Software"), to  deal in  the Software without  restriction, including
8  * without limitation  the rights to  use, copy, modify,  merge, publish,
9  * distribute,  sublicense, and/or sell  copies of  the Software,  and to
10  * permit persons to whom the Software  is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The  above  copyright  notice  and  this permission  notice  shall  be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
17  * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
18  * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 package org.slf4j.ext;
26 
27 import org.slf4j.LoggerFactory;
28 
29 /**
30  *
31  * This class is essentially a wrapper around an
32  * {@link LoggerFactory} producing {@link XLogger} instances.
33  *
34  * <p>Contrary to {@link LoggerFactory#getLogger(String)} method of
35  * {@link LoggerFactory}, each call to {@link #getXLogger(String)}
36  * produces a new instance of <code>XLogger</code>. This should not matter
37  * because an <code>XLogger</code> instance does not have any state beyond that of
38  * the {@link org.slf4j.Logger Logger} instance it wraps.
39  *
40  * @author Ralph Goers
41  * @author Ceki G&uuml;lc&uuml;
42  */
43 public class XLoggerFactory {
44 
45     /**
46      * Get an XLogger instance by name.
47      *
48      * @param name
49      * @return XLogger instance
50      */
getXLogger(String name)51     public static XLogger getXLogger(String name) {
52         return new XLogger(LoggerFactory.getLogger(name));
53     }
54 
55     /**
56      * Get a new XLogger instance by class. The returned XLogger
57      * will be named after the class.
58      *
59      * @param clazz
60      * @return XLogger instance by name
61      */
getXLogger(Class<?> clazz)62     public static XLogger getXLogger(Class<?> clazz) {
63         return getXLogger(clazz.getName());
64     }
65 }
66