Class Log

java.lang.Object
org.omegat.util.Log

public final class Log extends Object
A collection of methods to make logging things easier.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Compute the filename of the log file.
    static String
    Compute the full path of the log file.
    static tokyo.northside.logging.ILogger
    getLogger(Class<?> clazz)
     
    static String
    Returns the path to the log file.
    static String
     
     
    static boolean
    Checks whether debug-level logging is currently enabled.
    static void
    Logs what otherwise would go to System.out
    static void
    log(Throwable throwable)
    Logs an Exception or Error.
    static void
    log(Throwable throwable, String message, @Nullable Object... parameters)
     
    static void
    logDebug(String message, @Nullable Object... parameters)
    Logs a debug message with optional parameters.
    static void
    logDebug(Logger logger, String message, @Nullable Object... parameters)
    Deprecated, for removal: This API element is subject to removal in a future version. 
    static void
    logErrorRB(String key, @Nullable Object parameter)
    Writes an error message to the log (to be retrieved from the resource bundle).
    static void
    logErrorRB(String key, @Nullable Object... parameters)
    Writes an error message to the log (to be retrieved from the resource bundle)
    static void
    logErrorRB(Throwable ex, String key, @Nullable Object... parameters)
    Writes an error message to the log (to be retrieved from the resource bundle).
    static void
    Writes an info message to the log (to be retrieved from the resource bundle).
    static void
    logInfoRB(String key, @Nullable Object parameter)
    Writes an info message to the log (to be retrieved from the resource bundle).
    static void
    logInfoRB(String key, @Nullable Object... parameters)
    Writes an info message to the log (to be retrieved from the resource bundle).
    static void
    logRB(String key, @Nullable Object... parameters)
    Logs a message, retrieved from the resource bundle.
    static void
    logWarningRB(String key, @Nullable Object parameter)
    Writes a warning message to the log (to be retrieved from the resource bundle).
    static void
    logWarningRB(String key, @Nullable Object... parameters)
    Writes a warning message to the log (to be retrieved from the resource bundle)
    static void
    setLevel(Level level)
    Set the level for the global logger.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getSessionId

      public static String getSessionId()
    • getSessionStartDateTime

      public static ZonedDateTime getSessionStartDateTime()
    • getLogLocation

      public static String getLogLocation()
      Returns the path to the log file.
    • getLogFileName

      public static String getLogFileName()
      Compute the filename of the log file.
      Returns:
      the filename of the log, or an empty string
    • getLogFilePath

      public static String getLogFilePath()
      Compute the full path of the log file.
      Returns:
      the full path of the log file
    • setLevel

      public static void setLevel(Level level)
      Set the level for the global logger. This is normally determined by the logger.properties file; use this method to override for special use cases.
      Parameters:
      level - The new level
    • getLogger

      public static tokyo.northside.logging.ILogger getLogger(Class<?> clazz)
    • log

      public static void log(String s)
      Logs what otherwise would go to System.out
    • logRB

      public static void logRB(String key, @Nullable @Nullable Object... parameters)
      Logs a message, retrieved from the resource bundle.
      Parameters:
      key - The key of the message in the resource bundle.
      parameters - Parameters for the message. These are inserted by using StaticUtils.format.
    • log

      public static void log(Throwable throwable)
      Logs an Exception or Error. To the log are written: - The class name of the Exception or Error - The message, if any - The stack trace
      Parameters:
      throwable - The exception or error to log
    • log

      public static void log(Throwable throwable, String message, @Nullable @Nullable Object... parameters)
    • logWarningRB

      public static void logWarningRB(String key, @Nullable @Nullable Object... parameters)
      Writes a warning message to the log (to be retrieved from the resource bundle)

      While the warning message can be localized, the warning key is also logged, so developers can determine what warning was given by looking at the error key, instead of trying to interpret localized messages.

      Parameters:
      key - The key of the error message in the resource bundle
      parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
    • logInfoRB

      public static void logInfoRB(String key, @Nullable @Nullable Object... parameters)
      Writes an info message to the log (to be retrieved from the resource bundle).

      While the info message can be localized, the info key is also logged, so developers can determine what info was given by looking at the error key, instead of trying to interpret localized messages.

      Parameters:
      key - The key of the error message in the resource bundle
      parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
    • logErrorRB

      public static void logErrorRB(String key, @Nullable @Nullable Object... parameters)
      Writes an error message to the log (to be retrieved from the resource bundle)

      While the error message can be localized, the error key is also logged, so developers can determine what error was given by looking at the error key, instead of trying to interpret localized messages.

      Parameters:
      key - The key of the error message in the resource bundle
      parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
    • logErrorRB

      public static void logErrorRB(Throwable ex, String key, @Nullable @Nullable Object... parameters)
      Writes an error message to the log (to be retrieved from the resource bundle).

      While the error message can be localized, the error key is also logged, so developers can determine what error was given by looking at the error key, instead of trying to interpret localized messages.

      Parameters:
      ex - The error that was thrown
      key - The key of the error message in the resource bundle
      parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
    • logDebug

      @Deprecated(since="6.1.0", forRemoval=true) public static void logDebug(Logger logger, String message, @Nullable @Nullable Object... parameters)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Writes a debug message to log (without localization).
      Parameters:
      message - message text
      parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
    • isDebugEnabled

      public static boolean isDebugEnabled()
      Checks whether debug-level logging is currently enabled.
      Returns:
      true if debug-level logging is enabled, false otherwise
    • logDebug

      public static void logDebug(String message, @Nullable @Nullable Object... parameters)
      Logs a debug message with optional parameters. This method uses the debug logging level to record the provided message and arguments.
      Parameters:
      message - The message template to be logged. It may include placeholders for arguments.
      parameters - Optional arguments to be inserted into the placeholders of the message template.
    • logInfoRB

      public static void logInfoRB(String key, @Nullable @Nullable Object parameter)
      Writes an info message to the log (to be retrieved from the resource bundle).
      Parameters:
      key - The key of the error message in the resource bundle
      parameter - Parameter for the error message.
    • logInfoRB

      public static void logInfoRB(String key)
      Writes an info message to the log (to be retrieved from the resource bundle).
      Parameters:
      key - The key of the error message in the resource bundle
    • logWarningRB

      public static void logWarningRB(String key, @Nullable @Nullable Object parameter)
      Writes a warning message to the log (to be retrieved from the resource bundle).
      Parameters:
      key - The key of the error message in the resource bundle
      parameter - Parameter for the error message.
    • logErrorRB

      public static void logErrorRB(String key, @Nullable @Nullable Object parameter)
      Writes an error message to the log (to be retrieved from the resource bundle).