001package org.apache.archiva.common.utils; 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.slf4j.Logger; 023import org.slf4j.LoggerFactory; 024 025/** 026 * Slf4JPlexusLogger - temporary logger to provide an Slf4j Logger to those components 027 * outside of the archiva codebase that require a plexus logger. 028 * 029 * 030 */ 031public class Slf4JPlexusLogger 032 implements org.codehaus.plexus.logging.Logger 033{ 034 private final Logger log; 035 036 public Slf4JPlexusLogger( Class<?> clazz ) 037 { 038 log = LoggerFactory.getLogger( clazz ); 039 } 040 041 public Slf4JPlexusLogger( String name ) 042 { 043 log = LoggerFactory.getLogger( name ); 044 } 045 046 @Override 047 public void debug( String message ) 048 { 049 log.debug( message ); 050 } 051 052 @Override 053 public void debug( String message, Throwable throwable ) 054 { 055 log.debug( message, throwable ); 056 } 057 058 @Override 059 public void error( String message ) 060 { 061 log.error( message ); 062 } 063 064 @Override 065 public void error( String message, Throwable throwable ) 066 { 067 log.error( message, throwable ); 068 } 069 070 @Override 071 public void fatalError( String message ) 072 { 073 log.error( message ); 074 } 075 076 @Override 077 public void fatalError( String message, Throwable throwable ) 078 { 079 log.error( message, throwable ); 080 } 081 082 @Override 083 public org.codehaus.plexus.logging.Logger getChildLogger( String name ) 084 { 085 return new Slf4JPlexusLogger( log.getName() + "." + name ); 086 } 087 088 @Override 089 public String getName() 090 { 091 return log.getName(); 092 } 093 094 @Override 095 public int getThreshold() 096 { 097 if ( log.isTraceEnabled() ) 098 { 099 return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; 100 } 101 else if ( log.isDebugEnabled() ) 102 { 103 return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; 104 } 105 else if ( log.isInfoEnabled() ) 106 { 107 return org.codehaus.plexus.logging.Logger.LEVEL_INFO; 108 } 109 else if ( log.isWarnEnabled() ) 110 { 111 return org.codehaus.plexus.logging.Logger.LEVEL_WARN; 112 } 113 else if ( log.isErrorEnabled() ) 114 { 115 return org.codehaus.plexus.logging.Logger.LEVEL_ERROR; 116 } 117 118 return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED; 119 } 120 121 @Override 122 public void info( String message ) 123 { 124 log.info( message ); 125 } 126 127 @Override 128 public void info( String message, Throwable throwable ) 129 { 130 log.info( message, throwable ); 131 } 132 133 @Override 134 public boolean isDebugEnabled() 135 { 136 return log.isDebugEnabled(); 137 } 138 139 @Override 140 public boolean isErrorEnabled() 141 { 142 return log.isErrorEnabled(); 143 } 144 145 @Override 146 public boolean isFatalErrorEnabled() 147 { 148 return log.isErrorEnabled(); 149 } 150 151 @Override 152 public boolean isInfoEnabled() 153 { 154 return log.isInfoEnabled(); 155 } 156 157 @Override 158 public boolean isWarnEnabled() 159 { 160 return log.isWarnEnabled(); 161 } 162 163 @Override 164 public void setThreshold( int threshold ) 165 { 166 /* do nothing */ 167 } 168 169 @Override 170 public void warn( String message ) 171 { 172 log.warn( message ); 173 } 174 175 @Override 176 public void warn( String message, Throwable throwable ) 177 { 178 log.warn( message, throwable ); 179 } 180}