View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  
18  package org.apache.logging.log4j.jul;
19  
20  import org.apache.logging.log4j.Level;
21  import org.apache.logging.log4j.spi.ExtendedLogger;
22  import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;
23  
24  /**
25   * Wrapper class to ensure proper FQCN support in Logger calls.
26   *
27   * @since 2.1
28   */
29  class WrappedLogger extends ExtendedLoggerWrapper {
30  
31      private static final long serialVersionUID = 1L;
32      private static final String FQCN = ApiLogger.class.getName();
33  
34      WrappedLogger(final ExtendedLogger logger) {
35          super(logger, logger.getName(), logger.getMessageFactory());
36      }
37  
38      @Override
39      public void log(final Level level, final String message, final Throwable t) {
40          logIfEnabled(FQCN, level, null, message, t);
41      }
42  
43      @Override
44      public void log(final Level level, final String message, final Object... params) {
45          logIfEnabled(FQCN, level, null, message, params);
46      }
47  
48      @Override
49      public void log(final Level level, final String message) {
50          logIfEnabled(FQCN, level, null, message);
51      }
52  
53      @Override
54      public void entry() {
55          entry(FQCN);
56      }
57  
58      @Override
59      public void entry(final Object... params) {
60          entry(FQCN, params);
61      }
62  
63      @Override
64      public void exit() {
65          exit(FQCN, null);
66      }
67  
68      @Override
69      public <R> R exit(final R result) {
70          return exit(FQCN, result);
71      }
72  
73      @Override
74      public <T extends Throwable> T throwing(final T t) {
75          return throwing(FQCN, LevelTranslator.toLevel(java.util.logging.Level.FINER), t);
76      }
77  }