001package org.apache.maven.cli.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 * Adapt an SLF4J logger to a Plexus logger, ignoring Plexus logger API parts that are not classical and 026 * probably not really used. 027 * 028 * @author Jason van Zyl 029 * @since 3.1.0 030 */ 031public class Slf4jLogger 032 implements Logger 033{ 034 035 private org.slf4j.Logger logger; 036 037 public Slf4jLogger( org.slf4j.Logger logger ) 038 { 039 this.logger = logger; 040 } 041 042 public void debug( String message ) 043 { 044 logger.debug( message ); 045 } 046 047 public void debug( String message, Throwable throwable ) 048 { 049 logger.debug( message, throwable ); 050 } 051 052 public boolean isDebugEnabled() 053 { 054 return logger.isDebugEnabled(); 055 } 056 057 public void info( String message ) 058 { 059 logger.info( message ); 060 } 061 062 public void info( String message, Throwable throwable ) 063 { 064 logger.info( message, throwable ); 065 } 066 067 public boolean isInfoEnabled() 068 { 069 return logger.isInfoEnabled(); 070 } 071 072 public void warn( String message ) 073 { 074 logger.warn( message ); 075 } 076 077 public void warn( String message, Throwable throwable ) 078 { 079 logger.warn( message, throwable ); 080 } 081 082 public boolean isWarnEnabled() 083 { 084 return logger.isWarnEnabled(); 085 } 086 087 public void error( String message ) 088 { 089 logger.error( message ); 090 } 091 092 public void error( String message, Throwable throwable ) 093 { 094 logger.error( message, throwable ); 095 } 096 097 public boolean isErrorEnabled() 098 { 099 return logger.isErrorEnabled(); 100 } 101 102 public void fatalError( String message ) 103 { 104 logger.error( message ); 105 } 106 107 public void fatalError( String message, Throwable throwable ) 108 { 109 logger.error( message, throwable ); 110 } 111 112 public boolean isFatalErrorEnabled() 113 { 114 return logger.isErrorEnabled(); 115 } 116 117 /** 118 * <b>Warning</b>: ignored (always return <code>0 == Logger.LEVEL_DEBUG</code>). 119 */ 120 public int getThreshold() 121 { 122 return 0; 123 } 124 125 /** 126 * <b>Warning</b>: ignored. 127 */ 128 public void setThreshold( int threshold ) 129 { 130 } 131 132 /** 133 * <b>Warning</b>: ignored (always return <code>null</code>). 134 */ 135 public Logger getChildLogger( String name ) 136 { 137 return null; 138 } 139 140 public String getName() 141 { 142 return logger.getName(); 143 } 144 145}