View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.cli.logging;
20  
21  import org.codehaus.plexus.logging.Logger;
22  
23  /**
24   * Adapt an SLF4J logger to a Plexus logger, ignoring Plexus logger API parts that are not classical and
25   * probably not really used.
26   *
27   * @since 3.1.0
28   */
29  public class Slf4jLogger implements Logger {
30  
31      private org.slf4j.Logger logger;
32  
33      public Slf4jLogger(org.slf4j.Logger logger) {
34          this.logger = logger;
35      }
36  
37      public void debug(String message) {
38          logger.debug(message);
39      }
40  
41      public void debug(String message, Throwable throwable) {
42          logger.debug(message, throwable);
43      }
44  
45      public boolean isDebugEnabled() {
46          return logger.isDebugEnabled();
47      }
48  
49      public void info(String message) {
50          logger.info(message);
51      }
52  
53      public void info(String message, Throwable throwable) {
54          logger.info(message, throwable);
55      }
56  
57      public boolean isInfoEnabled() {
58          return logger.isInfoEnabled();
59      }
60  
61      public void warn(String message) {
62          logger.warn(message);
63      }
64  
65      public void warn(String message, Throwable throwable) {
66          logger.warn(message, throwable);
67      }
68  
69      public boolean isWarnEnabled() {
70          return logger.isWarnEnabled();
71      }
72  
73      public void error(String message) {
74          logger.error(message);
75      }
76  
77      public void error(String message, Throwable throwable) {
78          logger.error(message, throwable);
79      }
80  
81      public boolean isErrorEnabled() {
82          return logger.isErrorEnabled();
83      }
84  
85      public void fatalError(String message) {
86          logger.error(message);
87      }
88  
89      public void fatalError(String message, Throwable throwable) {
90          logger.error(message, throwable);
91      }
92  
93      public boolean isFatalErrorEnabled() {
94          return logger.isErrorEnabled();
95      }
96  
97      /**
98       * <b>Warning</b>: ignored (always return <code>0 == Logger.LEVEL_DEBUG</code>).
99       */
100     public int getThreshold() {
101         return 0;
102     }
103 
104     /**
105      * <b>Warning</b>: ignored.
106      */
107     public void setThreshold(int threshold) {}
108 
109     /**
110      * <b>Warning</b>: ignored (always return <code>null</code>).
111      */
112     public Logger getChildLogger(String name) {
113         return null;
114     }
115 
116     public String getName() {
117         return logger.getName();
118     }
119 }