All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.maven.doxia.logging.PlexusLoggerWrapper Maven / Gradle / Ivy

package org.apache.maven.doxia.logging;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.codehaus.plexus.logging.Logger;

/**
 * Wrap a Plexus logger into a Doxia logger.
 * Based on org.apache.maven.plugin.logging.Log.
 *
 * @author Vincent Siveton
 * @version $Id$
 * @since 1.1
 */
public class PlexusLoggerWrapper
    implements Log
{
    private final Logger logger;

    /**
     * 

Constructor for PlexusLoggerWrapper.

* * @param logger the Plexus logger to wrap. */ public PlexusLoggerWrapper( Logger logger ) { this.logger = logger; } /** {@inheritDoc} */ public void setLogLevel( int level ) { if ( level <= LEVEL_DEBUG ) { logger.setThreshold( Logger.LEVEL_DEBUG ); } else if ( level <= LEVEL_INFO ) { logger.setThreshold( Logger.LEVEL_INFO ); } else if ( level <= LEVEL_WARN ) { logger.setThreshold( Logger.LEVEL_WARN ); } else if ( level <= LEVEL_ERROR ) { logger.setThreshold( Logger.LEVEL_ERROR ); } else { logger.setThreshold( Logger.LEVEL_DISABLED ); } } /** {@inheritDoc} */ public void debug( CharSequence content ) { logger.debug( toString( content ) ); } /** {@inheritDoc} */ public void debug( CharSequence content, Throwable error ) { logger.debug( toString( content ), error ); } /** {@inheritDoc} */ public void debug( Throwable error ) { logger.debug( "", error ); } /** {@inheritDoc} */ public void info( CharSequence content ) { logger.info( toString( content ) ); } /** {@inheritDoc} */ public void info( CharSequence content, Throwable error ) { logger.info( toString( content ), error ); } /** {@inheritDoc} */ public void info( Throwable error ) { logger.info( "", error ); } /** {@inheritDoc} */ public void warn( CharSequence content ) { logger.warn( toString( content ) ); } /** {@inheritDoc} */ public void warn( CharSequence content, Throwable error ) { logger.warn( toString( content ), error ); } /** {@inheritDoc} */ public void warn( Throwable error ) { logger.warn( "", error ); } /** {@inheritDoc} */ public void error( CharSequence content ) { logger.error( toString( content ) ); } /** {@inheritDoc} */ public void error( CharSequence content, Throwable error ) { logger.error( toString( content ), error ); } /** {@inheritDoc} */ public void error( Throwable error ) { logger.error( "", error ); } /** {@inheritDoc} */ public boolean isDebugEnabled() { return logger.isDebugEnabled(); } /** {@inheritDoc} */ public boolean isInfoEnabled() { return logger.isInfoEnabled(); } /** {@inheritDoc} */ public boolean isWarnEnabled() { return logger.isWarnEnabled(); } /** {@inheritDoc} */ public boolean isErrorEnabled() { return logger.isErrorEnabled(); } // ---------------------------------------------------------------------- // Private methods // ---------------------------------------------------------------------- private String toString( CharSequence content ) { if ( content == null ) { return ""; } return content.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy