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.slf4j;
17  
18  import org.apache.ibatis.logging.Log;
19  import org.apache.ibatis.logging.LogFactory;
20  import org.slf4j.Marker;
21  import org.slf4j.MarkerFactory;
22  import org.slf4j.spi.LocationAwareLogger;
23  
24  /**
25   * @author Eduardo Macarron
26   */
27  class Slf4jLocationAwareLoggerImpl implements Log {
28  
29    private static final Marker MARKER = MarkerFactory.getMarker(LogFactory.MARKER);
30  
31    private static final String FQCN = Slf4jImpl.class.getName();
32  
33    private final LocationAwareLogger logger;
34  
35    Slf4jLocationAwareLoggerImpl(LocationAwareLogger logger) {
36      this.logger = logger;
37    }
38  
39    @Override
40    public boolean isDebugEnabled() {
41      return logger.isDebugEnabled();
42    }
43  
44    @Override
45    public boolean isTraceEnabled() {
46      return logger.isTraceEnabled();
47    }
48  
49    @Override
50    public void error(String s, Throwable e) {
51      logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, e);
52    }
53  
54    @Override
55    public void error(String s) {
56      logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, null);
57    }
58  
59    @Override
60    public void debug(String s) {
61      logger.log(MARKER, FQCN, LocationAwareLogger.DEBUG_INT, s, null, null);
62    }
63  
64    @Override
65    public void trace(String s) {
66      logger.log(MARKER, FQCN, LocationAwareLogger.TRACE_INT, s, null, null);
67    }
68  
69    @Override
70    public void warn(String s) {
71      logger.log(MARKER, FQCN, LocationAwareLogger.WARN_INT, s, null, null);
72    }
73  
74  }