Mercurial Hosting > nabble
diff src/fschmidt/util/log4j/CountingEvaluator.java @ 68:00520880ad02
add fschmidt source
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 05 Oct 2025 17:24:15 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fschmidt/util/log4j/CountingEvaluator.java Sun Oct 05 17:24:15 2025 -0600 @@ -0,0 +1,23 @@ +package fschmidt.util.log4j; + +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.TriggeringEventEvaluator; + + +public final class CountingEvaluator implements TriggeringEventEvaluator { + private final int limit; + private int count = 0; + + public CountingEvaluator(int limit) { + this.limit = limit; + } + + public boolean isTriggeringEvent(LoggingEvent event) { + if( ++count < limit ) { + return false; + } else { + count = 0; + return true; + } + } +}