Jdk14LoggingImpl.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.jdk14;

  17. import java.util.logging.Level;
  18. import java.util.logging.Logger;

  19. import org.apache.ibatis.logging.Log;

  20. /**
  21.  * @author Clinton Begin
  22.  */
  23. public class Jdk14LoggingImpl implements Log {

  24.   private final Logger log;

  25.   public Jdk14LoggingImpl(String clazz) {
  26.     log = Logger.getLogger(clazz);
  27.   }

  28.   @Override
  29.   public boolean isDebugEnabled() {
  30.     return log.isLoggable(Level.FINE);
  31.   }

  32.   @Override
  33.   public boolean isTraceEnabled() {
  34.     return log.isLoggable(Level.FINER);
  35.   }

  36.   @Override
  37.   public void error(String s, Throwable e) {
  38.     log.log(Level.SEVERE, s, e);
  39.   }

  40.   @Override
  41.   public void error(String s) {
  42.     log.log(Level.SEVERE, s);
  43.   }

  44.   @Override
  45.   public void debug(String s) {
  46.     log.log(Level.FINE, s);
  47.   }

  48.   @Override
  49.   public void trace(String s) {
  50.     log.log(Level.FINER, s);
  51.   }

  52.   @Override
  53.   public void warn(String s) {
  54.     log.log(Level.WARNING, s);
  55.   }

  56. }