001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package org.apache.geronimo.genesis.ant;
021    
022    import java.io.PrintStream;
023    
024    import org.apache.tools.ant.Project;
025    import org.apache.tools.ant.DefaultLogger;
026    
027    import org.apache.maven.plugin.logging.Log;
028    
029    /**
030     * Adapts Ant logging to Maven Logging.
031     *
032     * @version $Rev: 469680 $ $Date: 2006-10-31 14:23:54 -0800 (Tue, 31 Oct 2006) $
033     */
034    public class MavenAntLoggerAdapter
035        extends DefaultLogger
036    {
037        protected Log log;
038        
039        public MavenAntLoggerAdapter(final Log log) {
040            super();
041            
042            assert log != null;
043            
044            this.log = log;
045        }
046        
047        protected void printMessage(final String message, final PrintStream stream, final int priority) {
048            assert message != null;
049            assert stream != null;
050    
051            switch (priority) {
052                case Project.MSG_ERR:
053                    log.error(message);
054                    break;
055    
056                case Project.MSG_WARN:
057                    log.warn(message);
058                    break;
059    
060                case Project.MSG_INFO:
061                    log.info(message);
062                    break;
063    
064                case Project.MSG_VERBOSE:
065                case Project.MSG_DEBUG:
066                    log.debug(message);
067                    break;
068            }
069        }
070    }