View Javadoc
1   package com.simpligility.maven.plugins.android.common;
2   
3   import org.apache.maven.plugin.logging.Log;
4   import org.codehaus.plexus.logging.Logger;
5   
6   /**
7    * Maps from a Maven Logger to a Plexus Log.
8    */
9   public final class MavenToPlexusLogAdapter implements Logger
10  {
11  
12      private final Log delegate;
13  
14      public MavenToPlexusLogAdapter( Log delegate )
15      {
16          this.delegate = delegate;
17      }
18  
19      @Override
20      public void fatalError( String s )
21      {
22          delegate.error( s );
23      }
24  
25      @Override
26      public void fatalError( String s, Throwable throwable )
27      {
28          delegate.error( s, throwable );
29      }
30  
31      @Override
32      public void error( String content, Throwable error )
33      {
34          delegate.error( content, error );
35      }
36  
37      @Override
38      public void error( String content )
39      {
40          delegate.error( content );
41      }
42  
43      @Override
44      public void warn( String content )
45      {
46          delegate.warn( content );
47      }
48  
49      @Override
50      public void warn( String content, Throwable error )
51      {
52          delegate.warn( content, error );
53      }
54  
55      @Override
56      public void info( String content )
57      {
58          delegate.info( content );
59      }
60  
61      @Override
62      public void info( String content, Throwable error )
63      {
64          delegate.info( content, error );
65      }
66  
67      @Override
68      public void debug( String content )
69      {
70          delegate.debug( content );
71      }
72  
73      @Override
74      public void debug( String content, Throwable error )
75      {
76          delegate.debug( content, error );
77      }
78  
79      @Override
80      public boolean isDebugEnabled()
81      {
82          return delegate.isDebugEnabled();
83      }
84  
85      @Override
86      public boolean isInfoEnabled()
87      {
88          return delegate.isInfoEnabled();
89      }
90  
91      @Override
92      public boolean isWarnEnabled()
93      {
94          return delegate.isWarnEnabled();
95      }
96  
97      @Override
98      public boolean isErrorEnabled()
99      {
100         return delegate.isErrorEnabled();
101     }
102 
103     @Override
104     public boolean isFatalErrorEnabled()
105     {
106         return delegate.isErrorEnabled();
107     }
108 
109     @Override
110     public int getThreshold()
111     {
112         if ( delegate.isErrorEnabled() )
113         {
114             return Logger.LEVEL_ERROR;
115         }
116         else if ( delegate.isWarnEnabled() )
117         {
118             return Logger.LEVEL_WARN;
119         }
120         else if ( delegate.isInfoEnabled() )
121         {
122             return Logger.LEVEL_INFO;
123         }
124 
125         return Logger.LEVEL_DEBUG;
126     }
127 
128     @Override
129     public void setThreshold( int i )
130     {
131         // ignored
132     }
133 
134     @Override
135     public Logger getChildLogger( String s )
136     {
137         return null;
138     }
139 
140     @Override
141     public String getName()
142     {
143         return delegate.toString();
144     }
145 }