View Javadoc
1   /**
2    *    Copyright 2009-2019 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.logging.log4j;
17  
18  import org.apache.ibatis.logging.Log;
19  import org.apache.log4j.Level;
20  import org.apache.log4j.Logger;
21  
22  /**
23   * @author Eduardo Macarron
24   */
25  public class Log4jImpl implements Log {
26  
27    private static final String FQCN = Log4jImpl.class.getName();
28  
29    private final Logger log;
30  
31    public Log4jImpl(String clazz) {
32      log = Logger.getLogger(clazz);
33    }
34  
35    @Override
36    public boolean isDebugEnabled() {
37      return log.isDebugEnabled();
38    }
39  
40    @Override
41    public boolean isTraceEnabled() {
42      return log.isTraceEnabled();
43    }
44  
45    @Override
46    public void error(String s, Throwable e) {
47      log.log(FQCN, Level.ERROR, s, e);
48    }
49  
50    @Override
51    public void error(String s) {
52      log.log(FQCN, Level.ERROR, s, null);
53    }
54  
55    @Override
56    public void debug(String s) {
57      log.log(FQCN, Level.DEBUG, s, null);
58    }
59  
60    @Override
61    public void trace(String s) {
62      log.log(FQCN, Level.TRACE, s, null);
63    }
64  
65    @Override
66    public void warn(String s) {
67      log.log(FQCN, Level.WARN, s, null);
68    }
69  
70  }