Class Logger

java.lang.Object
esa.opensf.osfi.Logger

public final class Logger extends Object
Logger.
Manages the log messages raised.
  • Method Details

    • isDebugging

      public static boolean isDebugging()
      OSFI only writes messages with the "Debug" category to the actual log if the DEBUG_MODE environment variable is set to "On". Note that the environment variable is only checked the first time this is called.
      Returns:
      true if the system writes debug messages to the log, false otherwise.
    • isColored

      public static boolean isColored()
      OSFI writes log banners in colour if the OSFI_LOG_COLOR environment variable is set to "On". In that case, the colours used are:
      • Error: Red
      • Warning: Yellow
      • Progress: Cyan
      • Info: Green
      Note that the environment variable is only checked the first time this is called.
      Returns:
      true if the system writes coloured log banners, false otherwise.
    • error

      public static void error(String message)
      Shows a formatted error message.
      Parameters:
      message - - text of the message
    • warning

      public static void warning(String message)
      Shows a formatted warning message.
      Parameters:
      message - - text of the message
    • info

      public static void info(String message)
      Shows a formatted information message.
      Parameters:
      message - - text of the message
    • debug

      public static void debug(String message)
      Shows a formatted debug message, if the environment variable "DEBUG_MODE" is equal to "On". First time this function is called, checks the declaration of that variable. If it is not declared, presents a warning message and assumes it as "Off".
      Parameters:
      message - - text of the message
    • progress

      public static void progress(int step, int nSteps)
      Shows a formatted progress message.
      Parameters:
      step - - current step number
      nSteps - - maximum number of steps.
    • finishExecution

      public static void finishExecution(int errorCode)
      Shows an information message and exits the program execution with an specific error code.
      Parameters:
      errorCode - - Code of error to exit with.
    • qualityReport

      public static void qualityReport(String name, double value)
      Shows a formatted message reporting a quality indicator.
      Parameters:
      name - - Name of the quality indicator
      value - - Double associated to the quality indicator pointed by name
    • qualityReport

      public static void qualityReport(String name, String value)
      Shows a formatted message reporting a quality indicator.
      Parameters:
      name - - Name of the quality indicator
      value - - String associated to the quality indicator pointed by name
    • printMessage

      @Deprecated(since="3.8.0") public static void printMessage(String logType, String message, String fg, String bg)
      Deprecated.
      Internal function, to be removed from public API
      Shows a formatted information message of the given log type.
      Parameters:
      logType - Banner to be used before the first separator.
      message - Text after the first separator.
      fg - Colour code for the foreground, see Vt100.
      bg - Colour code for the brackgronund, see Vt100.
    • sysLoggerToOsfiLog

      public static System.Logger sysLoggerToOsfiLog()
      Equivalent to calling sysLoggerToOsfiLog(String) with a null context.
      Returns:
      JDK logger that forwards messages to the other methods in this class.
    • sysLoggerToOsfiLog

      public static System.Logger sysLoggerToOsfiLog(String context)
      Parameters:
      context - Used to prefix log messages, or null.
      Returns:
      JDK logger that forwards messages to the other methods in this class.
    • sysLoggerToOsfiLog

      public static System.Logger sysLoggerToOsfiLog(String context, System.Logger.Level minLvl)
      Creates a JDK logger implementation that sends any resulting messages to the OSFI log, by matching the log levels as follows:
      1. Any call with a level less severe than minLvl is ignored/dropped.
      2. ERROR or higher is sent to error(String).
      3. WARNING or higher is sent to warning(String).
      4. INFO or higher is sent to info(String).
      5. Any other value below INFO is sent to debug(String), where it may be dropped or written,depending on the status of isDebugging().
      The logger name is equal to context, or "OSFI" if null.
      Parameters:
      context - Used to prefix log messages, or null.
      minLvl - Messages with a level less severe than this will be ignored.
      Returns:
      JDK logger that forwards messages to the other methods in this class.