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