Package io.deephaven.logging
Class LogUtil
java.lang.Object
io.deephaven.logging.LogUtil
Utility class to help format logging messages.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 aLogEntry
.static com.fishlib.io.log.LogEntry
appendTimeMillis
(com.fishlib.io.log.LogEntry entry, long millis) Append time expressed as fractional seconds to aLogEntry
.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 usingcom.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 usingcom.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.
-
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 usingcom.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 usingcom.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 loggerlogPath
- the directory where to store the logsrollIntervalMs
- 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 aLogEntry
.- Parameters:
entry
- TheLogEntry
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 aLogEntry
.- Parameters:
entry
- TheLogEntry
where to do the log appending.millis
- Time to log in milliseconds.- Returns:
- the modified
LogEntry
to support chaining of operations
-
deltaMillisToHumanStr
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
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 bySystem.currentTimeMillis()
- Returns:
- a String with an ISO Date
-