MartinKanters commented on a change in pull request #287: [MNG-6065] - Log
fail-level option.
URL: https://github.com/apache/maven/pull/287#discussion_r351496658
##########
File path:
maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenFailLevelLoggerState.java
##########
@@ -19,29 +19,32 @@
* under the License.
*/
-import org.slf4j.Logger;
+import org.slf4j.event.Level;
/**
- * MavenSimpleLoggerFactory
+ * Responsible for keeping state of whether the threshold of the --fail-level
flag has been hit.
*/
-public class MavenSimpleLoggerFactory
- extends SimpleLoggerFactory
+class MavenFailLevelLoggerState
{
- /**
- * Return an appropriate {@link MavenSimpleLogger} instance by name.
- */
- public Logger getLogger( String name )
+ private final Level logThreshold;
+ private boolean thresholdHit = false;
+
+ MavenFailLevelLoggerState( Level logLevel )
{
- Logger simpleLogger = loggerMap.get( name );
- if ( simpleLogger != null )
- {
- return simpleLogger;
- }
- else
+ assert logLevel != null;
+ this.logThreshold = logLevel;
+ }
+
+ void recordLogLevel( Level logLevel )
+ {
+ if ( !thresholdHit && logLevel.toInt() >= logThreshold.toInt() )
{
- Logger newInstance = new MavenSimpleLogger( name );
- Logger oldInstance = loggerMap.putIfAbsent( name, newInstance );
- return oldInstance == null ? newInstance : oldInstance;
+ thresholdHit = true;
}
}
+
+ boolean threwLogsOfBreakingLevel()
Review comment:
The LogLevel being the threshold? Currently this class holds state whether
the threshold has been hit or not, would you rather like to see that in the
MavenLoggerFactory class?
Personally I would like to see as little as possible loggingLevelThreshold
in the MavenLoggerFactory and encapsulate that into the LogLevelRecorder
possibly.
Now that I think of it, what do you think of only making `LogLevelRecorder`
a field inside `MavenLoggerFactory` with just a getter on the
`MavenSlf4jWrapperFactory` interface?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services