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   * @author Jason van Zyl
28   * @since 3.1.0
29   */
30  public class Slf4jLogger implements Logger {
31  
32      private org.slf4j.Logger logger;
33  
34      public Slf4jLogger(org.slf4j.Logger logger) {
35          this.logger = logger;
36      }
37  
38      public void debug(String message) {
39          logger.debug(message);
40      }
41  
42      public void debug(String message, Throwable throwable) {
43          logger.debug(message, throwable);
44      }
45  
46      public boolean isDebugEnabled() {
47          return logger.isDebugEnabled();
48      }
49  
50      public void info(String message) {
51          logger.info(message);
52      }
53  
54      public void info(String message, Throwable throwable) {
55          logger.info(message, throwable);
56      }
57  
58      public boolean isInfoEnabled() {
59          return logger.isInfoEnabled();
60      }
61  
62      public void warn(String message) {
63          logger.warn(message);
64      }
65  
66      public void warn(String message, Throwable throwable) {
67          logger.warn(message, throwable);
68      }
69  
70      public boolean isWarnEnabled() {
71          return logger.isWarnEnabled();
72      }
73  
74      public void error(String message) {
75          logger.error(message);
76      }
77  
78      public void error(String message, Throwable throwable) {
79          logger.error(message, throwable);
80      }
81  
82      public boolean isErrorEnabled() {
83          return logger.isErrorEnabled();
84      }
85  
86      public void fatalError(String message) {
87          logger.error(message);
88      }
89  
90      public void fatalError(String message, Throwable throwable) {
91          logger.error(message, throwable);
92      }
93  
94      public boolean isFatalErrorEnabled() {
95          return logger.isErrorEnabled();
96      }
97  
98      /**
99       * <b>Warning</b>: ignored (always return <code>0 == Logger.LEVEL_DEBUG</code>).
100      */
101     public int getThreshold() {
102         return 0;
103     }
104 
105     /**
106      * <b>Warning</b>: ignored.
107      */
108     public void setThreshold(int threshold) {}
109 
110     /**
111      * <b>Warning</b>: ignored (always return <code>null</code>).
112      */
113     public Logger getChildLogger(String name) {
114         return null;
115     }
116 
117     public String getName() {
118         return logger.getName();
119     }
120 }