View Javadoc
1   package org.apache.maven.plugin.surefire.log;
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.apache.maven.plugin.surefire.log.api.ConsoleLogger;
23  import org.codehaus.plexus.logging.Logger;
24  
25  /**
26   * Wrapper logger of miscellaneous implementations of {@link Logger}.
27   *
28   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
29   * @since 2.20
30   * @see ConsoleLogger
31   */
32  public final class PluginConsoleLogger
33      implements ConsoleLogger
34  {
35      private final Logger plexusLogger;
36  
37      public PluginConsoleLogger( Logger plexusLogger )
38      {
39          this.plexusLogger = plexusLogger;
40      }
41  
42      @Override
43      public boolean isDebugEnabled()
44      {
45          return plexusLogger.isDebugEnabled();
46      }
47  
48      @Override
49      public void debug( String message )
50      {
51          plexusLogger.debug( message );
52      }
53  
54      public void debug( CharSequence content, Throwable error )
55      {
56          plexusLogger.debug( content == null ? "" : content.toString(), error );
57      }
58  
59      @Override
60      public boolean isInfoEnabled()
61      {
62          return plexusLogger.isInfoEnabled();
63      }
64  
65      @Override
66      public void info( String message )
67      {
68          plexusLogger.info( message );
69      }
70  
71      @Override
72      public boolean isWarnEnabled()
73      {
74          return plexusLogger.isWarnEnabled();
75      }
76  
77      @Override
78      public void warning( String message )
79      {
80          plexusLogger.warn( message );
81      }
82  
83      public void warning( CharSequence content, Throwable error )
84      {
85          plexusLogger.warn( content == null ? "" : content.toString(), error );
86      }
87  
88      @Override
89      public boolean isErrorEnabled()
90      {
91          return plexusLogger.isErrorEnabled() || plexusLogger.isFatalErrorEnabled();
92      }
93  
94      @Override
95      public void error( String message )
96      {
97          plexusLogger.error( message );
98      }
99  
100     @Override
101     public void error( String message, Throwable t )
102     {
103         plexusLogger.error( message, t );
104     }
105 
106     @Override
107     public void error( Throwable t )
108     {
109         plexusLogger.error( "", t );
110     }
111 }