View Javadoc
1   package org.apache.maven.scm.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  /**
23   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
24   */
25  public class DefaultLog
26      implements ScmLogger
27  {
28  
29      private boolean debug = false;
30  
31      public DefaultLog()
32      {
33          // no op
34      }
35  
36      public DefaultLog( boolean debug )
37      {
38          this.debug = debug;
39      }
40  
41      /**
42       * {@inheritDoc}
43       */
44      public boolean isDebugEnabled()
45      {
46          return this.debug;
47      }
48  
49      /**
50       * {@inheritDoc}
51       */
52      public void debug( String content )
53      {
54          if ( this.debug )
55          {
56              System.out.println( content );
57          }
58      }
59  
60      /**
61       * {@inheritDoc}
62       */
63      public void debug( String content, Throwable error )
64      {
65          if ( this.debug )
66          {
67              System.out.println( content );
68              error.printStackTrace();
69          }
70      }
71  
72      /**
73       * {@inheritDoc}
74       */
75      public void debug( Throwable error )
76      {
77          if ( this.debug )
78          {
79              error.printStackTrace();
80          }
81      }
82  
83      /**
84       * {@inheritDoc}
85       */
86      public boolean isInfoEnabled()
87      {
88          return true;
89      }
90  
91      /**
92       * {@inheritDoc}
93       */
94      public void info( String content )
95      {
96          System.out.println( content );
97      }
98  
99      /**
100      * {@inheritDoc}
101      */
102     public void info( String content, Throwable error )
103     {
104         System.out.println( content );
105         error.printStackTrace();
106     }
107 
108     /**
109      * {@inheritDoc}
110      */
111     public void info( Throwable error )
112     {
113         error.printStackTrace();
114     }
115 
116     /**
117      * {@inheritDoc}
118      */
119     public boolean isWarnEnabled()
120     {
121         return true;
122     }
123 
124     /**
125      * {@inheritDoc}
126      */
127     public void warn( String content )
128     {
129         System.out.println( content );
130     }
131 
132     /**
133      * {@inheritDoc}
134      */
135     public void warn( String content, Throwable error )
136     {
137         System.out.println( content );
138         error.printStackTrace();
139     }
140 
141     /**
142      * {@inheritDoc}
143      */
144     public void warn( Throwable error )
145     {
146         error.printStackTrace();
147     }
148 
149     /**
150      * {@inheritDoc}
151      */
152     public boolean isErrorEnabled()
153     {
154         return true;
155     }
156 
157     /**
158      * {@inheritDoc}
159      */
160     public void error( String content )
161     {
162         System.out.print( "[ERROR] " + content );
163     }
164 
165     /**
166      * {@inheritDoc}
167      */
168     public void error( String content, Throwable error )
169     {
170         System.out.println( "[ERROR] " + content );
171         error.printStackTrace();
172     }
173 
174     /**
175      * {@inheritDoc}
176      */
177     public void error( Throwable error )
178     {
179         error.printStackTrace();
180     }
181 }