001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.plugins.enforcer.internal; 020 021import java.util.Objects; 022import java.util.function.Supplier; 023 024import org.apache.maven.enforcer.rule.api.EnforcerLogger; 025import org.apache.maven.plugin.logging.Log; 026 027/** 028 * Base EnforcerLogger implementation 029 * 030 * @author Slawomir Jaranowski 031 * @since 3.2.0 032 */ 033public abstract class AbstractEnforcerLogger implements EnforcerLogger { 034 035 protected final Log log; 036 037 protected AbstractEnforcerLogger(Log log) { 038 this.log = Objects.requireNonNull(log, "log must be not null"); 039 } 040 041 @Override 042 public boolean isDebugEnabled() { 043 return log.isDebugEnabled(); 044 } 045 046 @Override 047 public void debug(CharSequence message) { 048 log.debug(message); 049 } 050 051 @Override 052 public void debug(Supplier<CharSequence> messageSupplier) { 053 if (log.isDebugEnabled()) { 054 log.debug(messageSupplier.get()); 055 } 056 } 057 058 @Override 059 public boolean isInfoEnabled() { 060 return log.isInfoEnabled(); 061 } 062 063 @Override 064 public void info(CharSequence message) { 065 log.info(message); 066 } 067 068 @Override 069 public void info(Supplier<CharSequence> messageSupplier) { 070 if (log.isInfoEnabled()) { 071 log.info(messageSupplier.get()); 072 } 073 } 074 075 @Override 076 public boolean isWarnEnabled() { 077 return log.isWarnEnabled(); 078 } 079 080 @Override 081 public void warn(CharSequence message) { 082 log.warn(message); 083 } 084 085 @Override 086 public void warn(Supplier<CharSequence> messageSupplier) { 087 if (log.isWarnEnabled()) { 088 log.warn(messageSupplier.get()); 089 } 090 } 091 092 @Override 093 public boolean isErrorEnabled() { 094 return log.isErrorEnabled(); 095 } 096 097 @Override 098 public void error(CharSequence message) { 099 log.error(message); 100 } 101 102 @Override 103 public void error(Supplier<CharSequence> messageSupplier) { 104 if (log.isErrorEnabled()) { 105 log.error(messageSupplier.get()); 106 } 107 } 108}