view 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 source

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;
		}
	}
}