001    package 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    
022    /**
023     * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
024     */
025    public class DefaultLog
026        implements ScmLogger
027    {
028    
029        private boolean debug = false;
030    
031        public DefaultLog()
032        {
033            // no op
034        }
035    
036        public DefaultLog( boolean debug )
037        {
038            this.debug = debug;
039        }
040    
041        /**
042         * {@inheritDoc}
043         */
044        public boolean isDebugEnabled()
045        {
046            return this.debug;
047        }
048    
049        /**
050         * {@inheritDoc}
051         */
052        public void debug( String content )
053        {
054            if ( this.debug )
055            {
056                System.out.println( content );
057            }
058        }
059    
060        /**
061         * {@inheritDoc}
062         */
063        public void debug( String content, Throwable error )
064        {
065            if ( this.debug )
066            {
067                System.out.println( content );
068                error.printStackTrace();
069            }
070        }
071    
072        /**
073         * {@inheritDoc}
074         */
075        public void debug( Throwable error )
076        {
077            if ( this.debug )
078            {
079                error.printStackTrace();
080            }
081        }
082    
083        /**
084         * {@inheritDoc}
085         */
086        public boolean isInfoEnabled()
087        {
088            return true;
089        }
090    
091        /**
092         * {@inheritDoc}
093         */
094        public void info( String content )
095        {
096            System.out.println( content );
097        }
098    
099        /**
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    }