rfscholte commented on a change in pull request #287: [MNG-6065] - Log
fail-level option.
URL: https://github.com/apache/maven/pull/287#discussion_r351447660
##########
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:
I can image that we need something more dynamic in the future, so I'd prefer
to pass the LogLevel here. And let's find a shorter method name (without threw).
----------------------------------------------------------------
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