Class StopwatchLogger

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class StopwatchLogger
    extends java.lang.Object
    implements java.io.Closeable
    Utility class to be used for tracking of timing within methods. It makes use of the Clock.Fast for speeding up the operation.
    • Constructor Summary

      Constructors 
      Constructor Description
      StopwatchLogger​(@NotNull java.lang.Class<?> clazz)
      instantiate a class with the provided class
      StopwatchLogger​(@NotNull java.lang.String clazz)
      Create a class with the provided class.
      StopwatchLogger​(@Nullable Logger customLog, @NotNull java.lang.Class<?> clazz)
      Instantiate a class with the provided class and custom logger.
      StopwatchLogger​(@Nullable Logger customLog, @NotNull java.lang.String clazz)
      Instantiate a class with the provided class and custom logger.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      boolean isEnabled()  
      boolean isStarted()  
      void split​(@Nullable java.lang.String message)
      track of an intermediate time without stopping the ticking.
      void start()
      starts the clock
      void stop​(@Nullable java.lang.String message)
      track the time and stop the clock.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StopwatchLogger

        public StopwatchLogger​(@NotNull
                               @NotNull java.lang.String clazz)
        Create a class with the provided class.
        Parameters:
        clazz -
      • StopwatchLogger

        public StopwatchLogger​(@NotNull
                               @NotNull java.lang.Class<?> clazz)
        instantiate a class with the provided class
        Parameters:
        clazz -
      • StopwatchLogger

        public StopwatchLogger​(@Nullable
                               @Nullable Logger customLog,
                               @NotNull
                               @NotNull java.lang.Class<?> clazz)
        Instantiate a class with the provided class and custom logger. The provided logger, if not null, will be then used for tracking down times
        Parameters:
        customLog -
        clazz -
      • StopwatchLogger

        public StopwatchLogger​(@Nullable
                               @Nullable Logger customLog,
                               @NotNull
                               @NotNull java.lang.String clazz)
        Instantiate a class with the provided class and custom logger. The provided logger, if not null, will be then used for tracking down times
        Parameters:
        customLog -
        clazz -
    • Method Detail

      • start

        public void start()
        starts the clock
      • split

        public void split​(@Nullable
                          @Nullable java.lang.String message)
        track of an intermediate time without stopping the ticking.
        Parameters:
        message -
      • stop

        public void stop​(@Nullable
                         @Nullable java.lang.String message)
        track the time and stop the clock.
        Parameters:
        message -
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • isStarted

        public boolean isStarted()
        Returns:
        true if the clock has been started. False otherwise.
      • isEnabled

        public boolean isEnabled()
        Returns:
        true whether the provided appender has DEBUG enabled and therefore asked to track times.