Class LogUtil

java.lang.Object
discord4j.common.LogUtil

public class LogUtil extends Object
Utility to support logging details.
  • Field Details

  • Constructor Details

    • LogUtil

      public LogUtil()
  • Method Details

    • format

      public static String format(ContextView context, String msg)
      Format a message by unwrapping certain ContextView values as metadata, and if they exist, prepend them to the given message.
      Parameters:
      context - a Reactor context to enrich the logging message
      msg - the logging message
      Returns:
      a formatted log message
    • formatValue

      public static String formatValue(@Nullable Object value, int maxLength)
      Format a given Object to a String, optionally limiting their length.
      Parameters:
      value - the value to format
      maxLength - maximum length of the formatted value if positive or impose no limit otherwise.
      Returns:
      a formatted value
    • traceDebug

      public static void traceDebug(Logger logger, Function<Boolean,String> messageFactory)
      Log a message depending on the enabled level for a given Logger. The supplied message factory will be applied with true if the logger has trace level enabled, given by Logger.isTraceEnabled(), o false otherwise.
      Parameters:
      logger - the logger instance used for logging a message
      messageFactory - a Function that takes true value if the given logger has trace level enabled, false otherwise, and produces a message to log.
    • clearContext

      public static Function<Context,Context> clearContext()