Slf4jLocationAwareLoggerImpl.java

  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.slf4j;

  17. import org.apache.ibatis.logging.Log;
  18. import org.apache.ibatis.logging.LogFactory;
  19. import org.slf4j.Marker;
  20. import org.slf4j.MarkerFactory;
  21. import org.slf4j.spi.LocationAwareLogger;

  22. /**
  23.  * @author Eduardo Macarron
  24.  */
  25. class Slf4jLocationAwareLoggerImpl implements Log {

  26.   private static final Marker MARKER = MarkerFactory.getMarker(LogFactory.MARKER);

  27.   private static final String FQCN = Slf4jImpl.class.getName();

  28.   private final LocationAwareLogger logger;

  29.   Slf4jLocationAwareLoggerImpl(LocationAwareLogger logger) {
  30.     this.logger = logger;
  31.   }

  32.   @Override
  33.   public boolean isDebugEnabled() {
  34.     return logger.isDebugEnabled();
  35.   }

  36.   @Override
  37.   public boolean isTraceEnabled() {
  38.     return logger.isTraceEnabled();
  39.   }

  40.   @Override
  41.   public void error(String s, Throwable e) {
  42.     logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, e);
  43.   }

  44.   @Override
  45.   public void error(String s) {
  46.     logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, null);
  47.   }

  48.   @Override
  49.   public void debug(String s) {
  50.     logger.log(MARKER, FQCN, LocationAwareLogger.DEBUG_INT, s, null, null);
  51.   }

  52.   @Override
  53.   public void trace(String s) {
  54.     logger.log(MARKER, FQCN, LocationAwareLogger.TRACE_INT, s, null, null);
  55.   }

  56.   @Override
  57.   public void warn(String s) {
  58.     logger.log(MARKER, FQCN, LocationAwareLogger.WARN_INT, s, null, null);
  59.   }

  60. }