Class LogHelper

java.lang.Object
com.helger.commons.log.LogHelper

@Immutable public final class LogHelper extends Object
Some utility functions to help integrating the IErrorLevel enum in this package with SLF4J logger.
Author:
Philip Helger
  • Method Details

    • getFuncIsEnabled

      @Nonnull public static LogHelper.IFuncIsLoggingEnabled getFuncIsEnabled(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel)
    • getFuncLogger

      @Nonnull public static LogHelper.IFuncLogger getFuncLogger(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel)
    • isEnabled

      public static boolean isEnabled(@Nonnull Class<?> aLoggingClass, @Nonnull IHasErrorLevel aErrorLevelProvider)
      Check if logging is enabled for the passed class based on the error level provider by the passed object
      Parameters:
      aLoggingClass - The class to determine the logger from. May not be null .
      aErrorLevelProvider - The error level provider. May not be null.
      Returns:
      true if the respective log level is allowed, false if not
    • isEnabled

      public static boolean isEnabled(@Nonnull org.slf4j.Logger aLogger, @Nonnull IHasErrorLevel aErrorLevelProvider)
      Check if logging is enabled for the passed logger based on the error level provider by the passed object
      Parameters:
      aLogger - The logger. May not be null.
      aErrorLevelProvider - The error level provider. May not be null.
      Returns:
      true if the respective log level is allowed, false if not
    • isEnabled

      public static boolean isEnabled(@Nonnull Class<?> aLoggingClass, @Nonnull IErrorLevel aErrorLevel)
      Check if logging is enabled for the passed class based on the error level provided
      Parameters:
      aLoggingClass - The class to determine the logger from. May not be null .
      aErrorLevel - The error level. May not be null.
      Returns:
      true if the respective log level is allowed, false if not
    • isEnabled

      public static boolean isEnabled(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel)
      Check if logging is enabled for the passed logger based on the error level provided
      Parameters:
      aLogger - The logger. May not be null.
      aErrorLevel - The error level. May not be null.
      Returns:
      true if the respective log level is allowed, false if not
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull String sMsg)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevelProvider - Error level provided to use. May not be null.
      sMsg - The message to log. May not be null.
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull String sMsg, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevelProvider - Error level provided to use. May not be null.
      sMsg - The message to log. May not be null.
      t - Optional exception that occurred. May be null.
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull String sMsg)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevelProvider - Error level provider to use. May not be null.
      sMsg - The message to log. May not be null.
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull String sMsg, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevelProvider - Error level provider to use. May not be null.
      sMsg - The message to log. May not be null.
      t - Optional exception that occurred. May be null.
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IErrorLevel aErrorLevel, @Nonnull String sMsg)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      sMsg - The message to log. May not be null.
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IErrorLevel aErrorLevel, @Nonnull String sMsg, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      sMsg - The message to log. May not be null.
      t - Optional exception that occurred. May be null.
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel, @Nonnull String sMsg)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      sMsg - The message to log. May not be null.
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel, @Nonnull String sMsg, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      sMsg - The message to log. May not be null.
      t - Optional exception that occurred. May be null.
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull Supplier<String> aMsgSupplier)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevelProvider - Error level provided to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull Supplier<String> aMsgSupplier, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevelProvider - Error level provided to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      t - Optional exception that occurred. May be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull Supplier<String> aMsgSupplier)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevelProvider - Error level provider to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IHasErrorLevel aErrorLevelProvider, @Nonnull Supplier<String> aMsgSupplier, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevelProvider - Error level provider to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      t - Optional exception that occurred. May be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IErrorLevel aErrorLevel, @Nonnull Supplier<String> aMsgSupplier)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull Class<?> aLoggingClass, @Nonnull IErrorLevel aErrorLevel, @Nonnull Supplier<String> aMsgSupplier, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLoggingClass - Logging class to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      t - Optional exception that occurred. May be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel, @Nonnull Supplier<String> aMsgSupplier)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      Since:
      9.1.3
    • log

      public static void log(@Nonnull org.slf4j.Logger aLogger, @Nonnull IErrorLevel aErrorLevel, @Nonnull Supplier<String> aMsgSupplier, @Nullable Throwable t)
      Generically log something
      Parameters:
      aLogger - Logger to use. May not be null.
      aErrorLevel - Error level to use. May not be null.
      aMsgSupplier - Message supplier to use. The supplier is only invoked if the log level is enabled on the provided logger. May not be null.
      t - Optional exception that occurred. May be null.
      Since:
      9.1.3