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.DefaultLogger; 025 import org.apache.tools.ant.Project; 026 import org.apache.commons.logging.Log; 027 028 /** 029 * Adapts Ant logging to Jakarta Commons Logging. 030 * 031 * @version $Rev: 454309 $ $Date: 2006-10-09 01:38:26 -0700 (Mon, 09 Oct 2006) $ 032 */ 033 public class CommonsLoggingAntLoggerAdapter 034 extends DefaultLogger 035 { 036 protected Log log; 037 038 public CommonsLoggingAntLoggerAdapter(final Log log) { 039 super(); 040 041 assert log != null; 042 043 this.log = log; 044 } 045 046 protected void printMessage(final String message, final PrintStream stream, final int priority) { 047 assert message != null; 048 assert stream != null; 049 050 switch (priority) { 051 case Project.MSG_ERR: 052 log.error(message); 053 break; 054 055 case Project.MSG_WARN: 056 log.warn(message); 057 break; 058 059 case Project.MSG_INFO: 060 log.info(message); 061 break; 062 063 case Project.MSG_VERBOSE: 064 case Project.MSG_DEBUG: 065 log.debug(message); 066 break; 067 } 068 } 069 }