001package org.apache.maven.scm.log; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.ArrayList; 023import java.util.List; 024 025/** 026 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 027 * 028 */ 029public class ScmLogDispatcher 030 implements ScmLogger 031{ 032 private List<ScmLogger> listeners = new ArrayList<ScmLogger>(); 033 034 public void addListener( ScmLogger logger ) 035 { 036 listeners.add( logger ); 037 } 038 039 /** {@inheritDoc} */ 040 public void debug( String content, Throwable error ) 041 { 042 for ( ScmLogger logger : listeners ) 043 { 044 logger.debug( content, error ); 045 } 046 } 047 048 /** {@inheritDoc} */ 049 public void debug( String content ) 050 { 051 for ( ScmLogger logger : listeners ) 052 { 053 logger.debug( content ); 054 } 055 } 056 057 /** {@inheritDoc} */ 058 public void debug( Throwable error ) 059 { 060 for ( ScmLogger logger : listeners ) 061 { 062 logger.debug( error ); 063 } 064 } 065 066 /** {@inheritDoc} */ 067 public void error( String content, Throwable error ) 068 { 069 for ( ScmLogger logger : listeners ) 070 { 071 logger.error( content, error ); 072 } 073 } 074 075 /** {@inheritDoc} */ 076 public void error( String content ) 077 { 078 for ( ScmLogger logger : listeners ) 079 { 080 logger.error( content ); 081 } 082 } 083 084 /** {@inheritDoc} */ 085 public void error( Throwable error ) 086 { 087 for ( ScmLogger logger : listeners ) 088 { 089 logger.error( error ); 090 } 091 } 092 093 /** {@inheritDoc} */ 094 public void info( String content, Throwable error ) 095 { 096 for ( ScmLogger logger : listeners ) 097 { 098 if ( logger.isInfoEnabled() ) 099 { 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}