mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-10-14 14:10:52 +00:00
Switch back to support only Maven 3.9.x
This commit is contained in:
@@ -75,14 +75,8 @@
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-slf4j-wrapper</artifactId>
|
||||
<version>${maven4.version}</version>
|
||||
<classifier>sources</classifier>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<artifactId>maven-slf4j-provider</artifactId>
|
||||
<version>${maven.version}</version>
|
||||
<classifier>sources</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
|
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.apache.maven.logwrapper.LogLevelRecorder;
|
||||
import org.slf4j.event.Level;
|
||||
|
||||
/**
|
||||
* A proxy which enhances the MavenSimpleLogger with functionality to track whether a logging threshold is hit.
|
||||
* Currently only support WARN and ERROR states, since it's been used for the --fail-on-severity flag.
|
||||
*/
|
||||
public class MvndFailOnSeverityLogger extends MvndSimpleLogger {
|
||||
private final LogLevelRecorder logLevelRecorder;
|
||||
|
||||
MvndFailOnSeverityLogger(String name, LogLevelRecorder logLevelRecorder) {
|
||||
super(name);
|
||||
this.logLevelRecorder = logLevelRecorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple implementation which always logs messages of level WARN
|
||||
* according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void warn(String msg) {
|
||||
super.warn(msg);
|
||||
logLevelRecorder.record(Level.WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform single parameter substitution before logging the message of level
|
||||
* WARN according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void warn(String format, Object arg) {
|
||||
super.warn(format, arg);
|
||||
logLevelRecorder.record(Level.WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform double parameter substitution before logging the message of level
|
||||
* WARN according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void warn(String format, Object arg1, Object arg2) {
|
||||
super.warn(format, arg1, arg2);
|
||||
logLevelRecorder.record(Level.WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform double parameter substitution before logging the message of level
|
||||
* WARN according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void warn(String format, Object... argArray) {
|
||||
super.warn(format, argArray);
|
||||
logLevelRecorder.record(Level.WARN);
|
||||
}
|
||||
|
||||
/** Log a message of level WARN, including an exception. */
|
||||
@Override
|
||||
public void warn(String msg, Throwable t) {
|
||||
super.warn(msg, t);
|
||||
logLevelRecorder.record(Level.WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple implementation which always logs messages of level ERROR
|
||||
* according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
super.error(msg);
|
||||
logLevelRecorder.record(Level.ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform single parameter substitution before logging the message of level
|
||||
* ERROR according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void error(String format, Object arg) {
|
||||
super.error(format, arg);
|
||||
logLevelRecorder.record(Level.ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform double parameter substitution before logging the message of level
|
||||
* ERROR according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void error(String format, Object arg1, Object arg2) {
|
||||
super.error(format, arg1, arg2);
|
||||
logLevelRecorder.record(Level.ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform double parameter substitution before logging the message of level
|
||||
* ERROR according to the format outlined above.
|
||||
*/
|
||||
@Override
|
||||
public void error(String format, Object... argArray) {
|
||||
super.error(format, argArray);
|
||||
logLevelRecorder.record(Level.ERROR);
|
||||
}
|
||||
|
||||
/** Log a message of level ERROR, including an exception. */
|
||||
@Override
|
||||
public void error(String msg, Throwable t) {
|
||||
super.error(msg, t);
|
||||
logLevelRecorder.record(Level.ERROR);
|
||||
}
|
||||
}
|
@@ -18,39 +18,22 @@
|
||||
*/
|
||||
package org.slf4j.impl;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.apache.maven.logwrapper.LogLevelRecorder;
|
||||
import org.apache.maven.logwrapper.MavenSlf4jWrapperFactory;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* LogFactory for Maven which can create a simple logger or one which, if set, fails the build on a severity threshold.
|
||||
*/
|
||||
public class MvndLoggerFactory implements MavenSlf4jWrapperFactory {
|
||||
private LogLevelRecorder logLevelRecorder = null;
|
||||
public class MvndLoggerFactory implements ILoggerFactory {
|
||||
private final ConcurrentMap<String, Logger> loggerMap = new ConcurrentHashMap<>();
|
||||
|
||||
public MvndLoggerFactory() {
|
||||
MvndSimpleLogger.lazyInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogLevelRecorder(LogLevelRecorder logLevelRecorder) {
|
||||
if (this.logLevelRecorder != null) {
|
||||
throw new IllegalStateException("LogLevelRecorder has already been set.");
|
||||
}
|
||||
|
||||
this.logLevelRecorder = logLevelRecorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<LogLevelRecorder> getLogLevelRecorder() {
|
||||
return Optional.ofNullable(logLevelRecorder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an appropriate {@link Logger} instance by name.
|
||||
*/
|
||||
@@ -62,10 +45,8 @@ public class MvndLoggerFactory implements MavenSlf4jWrapperFactory {
|
||||
private Logger getNewLoggingInstance(String name) {
|
||||
if (name.startsWith("org.mvndaemon.mvnd.daemon")) {
|
||||
return new MvndDaemonLogger(name);
|
||||
} else if (logLevelRecorder == null) {
|
||||
return new MvndSimpleLogger(name);
|
||||
} else {
|
||||
return new MvndFailOnSeverityLogger(name, logLevelRecorder);
|
||||
return new MvndSimpleLogger(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user