001 package 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 022 import org.slf4j.Logger; 023 import 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 */ 031 public class Slf4JPlexusLogger 032 implements org.codehaus.plexus.logging.Logger 033 { 034 private 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 public void debug( String message ) 047 { 048 log.debug( message ); 049 } 050 051 public void debug( String message, Throwable throwable ) 052 { 053 log.debug( message, throwable ); 054 } 055 056 public void error( String message ) 057 { 058 log.error( message ); 059 } 060 061 public void error( String message, Throwable throwable ) 062 { 063 log.error( message, throwable ); 064 } 065 066 public void fatalError( String message ) 067 { 068 log.error( message ); 069 } 070 071 public void fatalError( String message, Throwable throwable ) 072 { 073 log.error( message, throwable ); 074 } 075 076 public org.codehaus.plexus.logging.Logger getChildLogger( String name ) 077 { 078 return new Slf4JPlexusLogger( log.getName() + "." + name ); 079 } 080 081 public String getName() 082 { 083 return log.getName(); 084 } 085 086 public int getThreshold() 087 { 088 if ( log.isTraceEnabled() ) 089 { 090 return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; 091 } 092 else if ( log.isDebugEnabled() ) 093 { 094 return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; 095 } 096 else if ( log.isInfoEnabled() ) 097 { 098 return org.codehaus.plexus.logging.Logger.LEVEL_INFO; 099 } 100 else if ( log.isWarnEnabled() ) 101 { 102 return org.codehaus.plexus.logging.Logger.LEVEL_WARN; 103 } 104 else if ( log.isErrorEnabled() ) 105 { 106 return org.codehaus.plexus.logging.Logger.LEVEL_ERROR; 107 } 108 109 return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED; 110 } 111 112 public void info( String message ) 113 { 114 log.info( message ); 115 } 116 117 public void info( String message, Throwable throwable ) 118 { 119 log.info( message, throwable ); 120 } 121 122 public boolean isDebugEnabled() 123 { 124 return log.isDebugEnabled(); 125 } 126 127 public boolean isErrorEnabled() 128 { 129 return log.isErrorEnabled(); 130 } 131 132 public boolean isFatalErrorEnabled() 133 { 134 return log.isErrorEnabled(); 135 } 136 137 public boolean isInfoEnabled() 138 { 139 return log.isInfoEnabled(); 140 } 141 142 public boolean isWarnEnabled() 143 { 144 return log.isWarnEnabled(); 145 } 146 147 public void setThreshold( int threshold ) 148 { 149 /* do nothing */ 150 } 151 152 public void warn( String message ) 153 { 154 log.warn( message ); 155 } 156 157 public void warn( String message, Throwable throwable ) 158 { 159 log.warn( message, throwable ); 160 } 161 }