Class TimestampingLogger


  • @Beta
    public class TimestampingLogger
    extends Object
    A simple way to log timing information about a repeated operation.

    This is intended to be used for a single logical operation which contains multiple steps, or for the same operation repeated over a collection. For example, an order operation with separate steps to find a user, create a new order linked to the user, and insert the order to a database. Or, some kind of data migration that loops over records in a source database table and writes to a new target database table.

    Currently, this is intended only to be used within a single thread.

    • Constructor Detail

      • TimestampingLogger

        public TimestampingLogger​(org.slf4j.Logger logger)
        Create a new instance using the given Logger.
    • Method Detail

      • traceLogElapsed

        public void traceLogElapsed​(String message,
                                    Object... args)
        Logs a message and elapsed time message at TRACE level.
        Parameters:
        message - the message or message template
        args - the arguments to the message template, if any
        See Also:
        logElapsed(Level, String, Object...)
      • debugLogElapsed

        public void debugLogElapsed​(String message,
                                    Object... args)
        Logs a message and elapsed time message at DEBUG level.
        Parameters:
        message - the message or message template
        args - the arguments to the message template, if any
        See Also:
        logElapsed(Level, String, Object...)
      • logElapsed

        public void logElapsed​(org.slf4j.event.Level level,
                               String message,
                               Object... args)
        Logs the given message, and then logs the elapsed time since the previous log. This results in two separate log messages.
        Parameters:
        level - the level at which to log the message and elapsed time message
        message - the message or message template
        args - the arguments to the message template, if any
      • traceLogAppendingElapsed

        public void traceLogAppendingElapsed​(String message,
                                             Object... args)
        Logs a message at TRACE level and appends an elapsed time message.
        Parameters:
        message - the message or message template
        args - the arguments to the message template, if any
        See Also:
        logAppendingElapsed(Level, String, Object...)
      • debugLogAppendingElapsed

        public void debugLogAppendingElapsed​(String message,
                                             Object... args)
        Logs a message at DEBUG level and appends an elapsed time message.
        Parameters:
        message - the message or message template
        args - the arguments to the message template, if any
        See Also:
        logAppendingElapsed(Level, String, Object...)
      • logAppendingElapsed

        public void logAppendingElapsed​(org.slf4j.event.Level level,
                                        String message,
                                        Object... args)
        Logs a message at the given level and appends an elapsed time message. This results in a single log message containing the original message followed by the elapsed time message.
        Parameters:
        level - the level at which to log the message and elapsed time message
        message - the message or message template
        args - the arguments to the message template, if any