Class ThrottlingLogger


  • public class ThrottlingLogger
    extends java.lang.Object
    Will limit the number of log messages emitted, so as not to spam when problems are happening.

    This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

    • Constructor Summary

      Constructors 
      Constructor Description
      ThrottlingLogger​(java.util.logging.Logger delegate)
      Create a new logger which will enforce a max number of messages per minute.
      ThrottlingLogger​(java.util.logging.Logger delegate, Clock clock)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void doLog​(java.util.logging.Level level, java.lang.String message, java.lang.Throwable throwable)  
      boolean isLoggable​(java.util.logging.Level level)
      Returns whether the current wrapped logger is set to log at the given level.
      void log​(java.util.logging.Level level, java.lang.String message)
      Log a message at the given level.
      void log​(java.util.logging.Level level, java.lang.String message, java.lang.Throwable throwable)
      Log a message at the given level with a throwable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rateTimeUnit

        private static final java.util.concurrent.TimeUnit rateTimeUnit
      • delegate

        private final java.util.logging.Logger delegate
      • throttled

        private final java.util.concurrent.atomic.AtomicBoolean throttled
      • fastRateLimiter

        private final RateLimiter fastRateLimiter
      • throttledRateLimiter

        private final RateLimiter throttledRateLimiter
    • Constructor Detail

      • ThrottlingLogger

        public ThrottlingLogger​(java.util.logging.Logger delegate)
        Create a new logger which will enforce a max number of messages per minute.
      • ThrottlingLogger

        ThrottlingLogger​(java.util.logging.Logger delegate,
                         Clock clock)
    • Method Detail

      • log

        public void log​(java.util.logging.Level level,
                        java.lang.String message)
        Log a message at the given level.
      • log

        public void log​(java.util.logging.Level level,
                        java.lang.String message,
                        @Nullable
                        java.lang.Throwable throwable)
        Log a message at the given level with a throwable.
      • doLog

        private void doLog​(java.util.logging.Level level,
                           java.lang.String message,
                           @Nullable
                           java.lang.Throwable throwable)
      • isLoggable

        public boolean isLoggable​(java.util.logging.Level level)
        Returns whether the current wrapped logger is set to log at the given level.
        Returns:
        true if the logger set to log at the requested level.