001package org.apache.maven.doxia.logging; 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 org.codehaus.plexus.logging.Logger; 023 024/** 025 * Wrap a Plexus logger into a Doxia logger. 026 * Based on org.apache.maven.plugin.logging.Log. 027 * 028 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> 029 * @since 1.1 030 */ 031@Deprecated 032public class PlexusLoggerWrapper 033 implements Log 034{ 035 private final Logger logger; 036 037 /** 038 * <p>Constructor for PlexusLoggerWrapper.</p> 039 * 040 * @param logger the Plexus logger to wrap. 041 */ 042 public PlexusLoggerWrapper( Logger logger ) 043 { 044 this.logger = logger; 045 } 046 047 /** {@inheritDoc} */ 048 public void setLogLevel( int level ) 049 { 050 if ( level <= LEVEL_DEBUG ) 051 { 052 logger.setThreshold( Logger.LEVEL_DEBUG ); 053 } 054 else if ( level <= LEVEL_INFO ) 055 { 056 logger.setThreshold( Logger.LEVEL_INFO ); 057 } 058 else if ( level <= LEVEL_WARN ) 059 { 060 logger.setThreshold( Logger.LEVEL_WARN ); 061 } 062 else if ( level <= LEVEL_ERROR ) 063 { 064 logger.setThreshold( Logger.LEVEL_ERROR ); 065 } 066 else 067 { 068 logger.setThreshold( Logger.LEVEL_DISABLED ); 069 } 070 } 071 072 /** 073 * {@inheritDoc} 074 * 075 * @param content a {@link java.lang.CharSequence} object. 076 */ 077 public void debug( CharSequence content ) 078 { 079 logger.debug( toString( content ) ); 080 } 081 082 /** {@inheritDoc} */ 083 public void debug( CharSequence content, Throwable error ) 084 { 085 logger.debug( toString( content ), error ); 086 } 087 088 /** {@inheritDoc} */ 089 public void debug( Throwable error ) 090 { 091 logger.debug( "", error ); 092 } 093 094 /** {@inheritDoc} */ 095 public void info( CharSequence content ) 096 { 097 logger.info( toString( content ) ); 098 } 099 100 /** {@inheritDoc} */ 101 public void info( CharSequence content, Throwable error ) 102 { 103 logger.info( toString( content ), error ); 104 } 105 106 /** 107 * {@inheritDoc} 108 * 109 * @param error a {@link java.lang.Throwable} object. 110 */ 111 public void info( Throwable error ) 112 { 113 logger.info( "", error ); 114 } 115 116 /** 117 * {@inheritDoc} 118 * 119 * @param content a {@link java.lang.CharSequence} object. 120 */ 121 public void warn( CharSequence content ) 122 { 123 logger.warn( toString( content ) ); 124 } 125 126 /** {@inheritDoc} */ 127 public void warn( CharSequence content, Throwable error ) 128 { 129 logger.warn( toString( content ), error ); 130 } 131 132 /** {@inheritDoc} */ 133 public void warn( Throwable error ) 134 { 135 logger.warn( "", error ); 136 } 137 138 /** {@inheritDoc} */ 139 public void error( CharSequence content ) 140 { 141 logger.error( toString( content ) ); 142 } 143 144 /** {@inheritDoc} */ 145 public void error( CharSequence content, Throwable error ) 146 { 147 logger.error( toString( content ), error ); 148 } 149 150 /** 151 * {@inheritDoc} 152 * 153 * @param error a {@link java.lang.Throwable} object. 154 */ 155 public void error( Throwable error ) 156 { 157 logger.error( "", error ); 158 } 159 160 /** 161 * {@inheritDoc} 162 * 163 * @return a boolean. 164 */ 165 public boolean isDebugEnabled() 166 { 167 return logger.isDebugEnabled(); 168 } 169 170 /** 171 * {@inheritDoc} 172 * 173 * @return a boolean. 174 */ 175 public boolean isInfoEnabled() 176 { 177 return logger.isInfoEnabled(); 178 } 179 180 /** 181 * {@inheritDoc} 182 * 183 * @return a boolean. 184 */ 185 public boolean isWarnEnabled() 186 { 187 return logger.isWarnEnabled(); 188 } 189 190 /** 191 * {@inheritDoc} 192 * 193 * @return a boolean. 194 */ 195 public boolean isErrorEnabled() 196 { 197 return logger.isErrorEnabled(); 198 } 199 200 // ---------------------------------------------------------------------- 201 // Private methods 202 // ---------------------------------------------------------------------- 203 204 private String toString( CharSequence content ) 205 { 206 if ( content == null ) 207 { 208 return ""; 209 } 210 211 return content.toString(); 212 } 213}