Class LogAggregator


  • public class LogAggregator
    extends Object
    A simple aggregator to prevent a burst of regularly repeated messages from flooding the logs. Messages known to be generated for an event occurring very frequently, for every protocol message or periodically, can be logged at first occurrence and then only at increasing intervals.
    • Constructor Detail

      • LogAggregator

        public LogAggregator()
    • Method Detail

      • log

        public void log​(Consumer<LocalizableMessage> logMethod,
                        LocalizableMessage message)
        Log a message and start the aggregation for it.

        The message will be logged right away and if repeated, at fixed intervals. In case of burst (more than 20 times in a second), there will be a warning about it.

        Parameters:
        logMethod - how to log the message
        message - the message
      • logAndPurge

        public void logAndPurge()
        Log message bursts and purge expired messages.