View Javadoc
1   /*
2    *    Copyright 2009-2022 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    *       https://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.log4j2;
17  
18  import org.apache.ibatis.logging.Log;
19  import org.apache.ibatis.logging.LogFactory;
20  import org.apache.logging.log4j.Logger;
21  import org.apache.logging.log4j.Marker;
22  import org.apache.logging.log4j.MarkerManager;
23  
24  /**
25   * @author Eduardo Macarron
26   */
27  public class Log4j2LoggerImpl implements Log {
28  
29    private static final Marker MARKER = MarkerManager.getMarker(LogFactory.MARKER);
30  
31    private final Logger log;
32  
33    public Log4j2LoggerImpl(Logger logger) {
34      log = logger;
35    }
36  
37    @Override
38    public boolean isDebugEnabled() {
39      return log.isDebugEnabled();
40    }
41  
42    @Override
43    public boolean isTraceEnabled() {
44      return log.isTraceEnabled();
45    }
46  
47    @Override
48    public void error(String s, Throwable e) {
49      log.error(MARKER, s, e);
50    }
51  
52    @Override
53    public void error(String s) {
54      log.error(MARKER, s);
55    }
56  
57    @Override
58    public void debug(String s) {
59      log.debug(MARKER, s);
60    }
61  
62    @Override
63    public void trace(String s) {
64      log.trace(MARKER, s);
65    }
66  
67    @Override
68    public void warn(String s) {
69      log.warn(MARKER, s);
70    }
71  
72  }