Class LogUtil

java.lang.Object
io.deephaven.logging.LogUtil

public class LogUtil extends Object
Utility class to help format logging messages.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.fishlib.io.log.LogEntry
    appendDeltaTimeMillis(com.fishlib.io.log.LogEntry entry, long startMillis, long endMillis)
    Append a delta time expressed as fractional seconds to a LogEntry.
    static com.fishlib.io.log.LogEntry
    appendTimeMillis(com.fishlib.io.log.LogEntry entry, long millis)
    Append time expressed as fractional seconds to a LogEntry.
    static String
    deltaMillisToHumanStr(long millis)
    Given a time period (NOT an absolute time) given as a number of milliseconds, produce a string of the form "2h20m30.501s" (for abbreviating "2 hours 20 minutes 30.501 seconds").
    static com.fishlib.io.logger.Logger
    setupProcessUnsafeLogger(String logName, com.fishlib.configuration.Configuration conf)
    Create a logger using com.fishlib.logger.ProcessUnsafeLogCreator and set it up as a standard logger for a process.
    static com.fishlib.io.logger.Logger
    setupProcessUnsafeLogger(String logName, com.fishlib.configuration.Configuration conf, String logPath, int rollIntervalMs)
    Create a logger using com.fishlib.logger.ProcessUnsafeLogCreator and set it up as a standard logger for a process.
    static String
    toIsoDateStr(long millis)
    Given an absolute time point (not a duration) in milliseconds since the epoch, produce an ISO Date string representation of it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LogUtil

      public LogUtil()
  • Method Details

    • setupProcessUnsafeLogger

      public static com.fishlib.io.logger.Logger setupProcessUnsafeLogger(String logName, com.fishlib.configuration.Configuration conf)
      Create a logger using com.fishlib.logger.ProcessUnsafeLogCreator and set it up as a standard logger for a process.
      Parameters:
      logName - the basename to use for the log file. A common choice is a program's main class simple name.
      conf - the configuration to use to set up the logger.
      Returns:
      a Logger object configured and ready to be used
    • setupProcessUnsafeLogger

      public static com.fishlib.io.logger.Logger setupProcessUnsafeLogger(String logName, com.fishlib.configuration.Configuration conf, String logPath, int rollIntervalMs)
      Create a logger using com.fishlib.logger.ProcessUnsafeLogCreator and set it up as a standard logger for a process.
      Parameters:
      logName - the basename to use for the log file. A common choice is a program's main class simple name.
      conf - the configuration to use to set up the logger
      logPath - the directory where to store the logs
      rollIntervalMs - the time period to use to roll the logs
      Returns:
      a Logger object configured and ready to be used
    • appendDeltaTimeMillis

      public static com.fishlib.io.log.LogEntry appendDeltaTimeMillis(com.fishlib.io.log.LogEntry entry, long startMillis, long endMillis)
      Append a delta time expressed as fractional seconds to a LogEntry.
      Parameters:
      entry - The LogEntry where to do the log appending.
      startMillis - The absolute time in milliseconds where the delta period to log starts.
      endMillis - The absolute time in milliseconds where the delta period to log ends.
      Returns:
      the modified LogEntry to support chaining of operations
    • appendTimeMillis

      public static com.fishlib.io.log.LogEntry appendTimeMillis(com.fishlib.io.log.LogEntry entry, long millis)
      Append time expressed as fractional seconds to a LogEntry.
      Parameters:
      entry - The LogEntry where to do the log appending.
      millis - Time to log in milliseconds.
      Returns:
      the modified LogEntry to support chaining of operations
    • deltaMillisToHumanStr

      public static String deltaMillisToHumanStr(long millis)
      Given a time period (NOT an absolute time) given as a number of milliseconds, produce a string of the form "2h20m30.501s" (for abbreviating "2 hours 20 minutes 30.501 seconds").
      • If hours is zero, minutes are included only if non zero.
      • If the number of milliseconds is less than 1 second, the zero for seconds is always included.
      • There are always three decimal places for fractional seconds.

      Examples:

      • for 3,601,000 millis, the result is "1h0m1.000s"
      • for 120 millis, the result is "0.120s"
      Parameters:
      millis - a time period (delta time) in milliseconds
      Returns:
      A string of the form "1h2m3.456s"
    • toIsoDateStr

      public static String toIsoDateStr(long millis)
      Given an absolute time point (not a duration) in milliseconds since the epoch, produce an ISO Date string representation of it. Useful for logging
      Parameters:
      millis - an absolute timestamp in milliseconds since the epoch, eg as produced by System.currentTimeMillis()
      Returns:
      a String with an ISO Date