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  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
27   *
28   */
29  public class ScmLogDispatcher
30      implements ScmLogger
31  {
32      private List<ScmLogger> listeners = new ArrayList<ScmLogger>();
33  
34      public void addListener( ScmLogger logger )
35      {
36          listeners.add( logger );
37      }
38  
39      /** {@inheritDoc} */
40      public void debug( String content, Throwable error )
41      {
42          for ( ScmLogger logger : listeners )
43          {
44              logger.debug( content, error );
45          }
46      }
47  
48      /** {@inheritDoc} */
49      public void debug( String content )
50      {
51          for ( ScmLogger logger : listeners )
52          {
53              logger.debug( content );
54          }
55      }
56  
57      /** {@inheritDoc} */
58      public void debug( Throwable error )
59      {
60          for ( ScmLogger logger : listeners )
61          {
62              logger.debug( error );
63          }
64      }
65  
66      /** {@inheritDoc} */
67      public void error( String content, Throwable error )
68      {
69          for ( ScmLogger logger : listeners )
70          {
71              logger.error( content, error );
72          }
73      }
74  
75      /** {@inheritDoc} */
76      public void error( String content )
77      {
78          for ( ScmLogger logger : listeners )
79          {
80              logger.error( content );
81          }
82      }
83  
84      /** {@inheritDoc} */
85      public void error( Throwable error )
86      {
87          for ( ScmLogger logger : listeners )
88          {
89              logger.error( error );
90          }
91      }
92  
93      /** {@inheritDoc} */
94      public void info( String content, Throwable error )
95      {
96          for ( ScmLogger logger : listeners )
97          {
98              if ( logger.isInfoEnabled() )
99              {
100                 logger.info( content, error );
101             }
102         }
103     }
104 
105     /** {@inheritDoc} */
106     public void info( String content )
107     {
108         for ( ScmLogger logger : listeners )
109         {
110             if ( logger.isInfoEnabled() )
111             {
112                 logger.info( content );
113             }
114         }
115     }
116 
117     /** {@inheritDoc} */
118     public void info( Throwable error )
119     {
120         for ( ScmLogger logger : listeners )
121         {
122             if ( logger.isInfoEnabled() )
123             {
124                 logger.info( error );
125             }
126         }
127     }
128 
129     /** {@inheritDoc} */
130     public boolean isDebugEnabled()
131     {
132         for ( ScmLogger logger : listeners )
133         {
134             if ( logger.isDebugEnabled() )
135             {
136                 return true;
137             }
138         }
139 
140         return false;
141     }
142 
143     /** {@inheritDoc} */
144     public boolean isErrorEnabled()
145     {
146         for ( ScmLogger logger : listeners )
147         {
148             if ( logger.isErrorEnabled() )
149             {
150                 return true;
151             }
152         }
153 
154         return false;
155     }
156 
157     /** {@inheritDoc} */
158     public boolean isInfoEnabled()
159     {
160         for ( ScmLogger logger : listeners )
161         {
162             if ( logger.isInfoEnabled() )
163             {
164                 return true;
165             }
166         }
167 
168         return false;
169     }
170 
171     /** {@inheritDoc} */
172     public boolean isWarnEnabled()
173     {
174         for ( ScmLogger logger : listeners )
175         {
176             if ( logger.isWarnEnabled() )
177             {
178                 return true;
179             }
180         }
181 
182         return false;
183     }
184 
185     /** {@inheritDoc} */
186     public void warn( String content, Throwable error )
187     {
188         for ( ScmLogger logger : listeners )
189         {
190             logger.warn( content, error );
191         }
192     }
193 
194     /** {@inheritDoc} */
195     public void warn( String content )
196     {
197         for ( ScmLogger logger : listeners )
198         {
199             logger.warn( content );
200         }
201     }
202 
203     /** {@inheritDoc} */
204     public void warn( Throwable error )
205     {
206         for ( ScmLogger logger : listeners )
207         {
208             logger.warn( error );
209         }
210     }
211 }