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