Class Phase4LogCustomizer

java.lang.Object
com.helger.phase4.logging.Phase4LogCustomizer

@ThreadSafe public final class Phase4LogCustomizer extends Object
The logging customizer for the phase4 library.
Since:
3.1.0-beta3
Author:
Philip Helger
  • Method Details

    • getThreadLocalLogPrefix

      public static @Nullable String getThreadLocalLogPrefix()
      Get the current thread local log prefix.
      Returns:
      The current thread local log prefix. May be null.
    • setThreadLocalLogPrefix

      public static void setThreadLocalLogPrefix(@Nullable String sPrefix)
      Set the current thread local log prefix.
      Parameters:
      sPrefix - The prefix to set. May be null.
    • getThreadLocalLogSuffix

      public static @Nullable String getThreadLocalLogSuffix()
      Get the current thread local log suffix.
      Returns:
      The current thread local log suffix. May be null.
    • setThreadLocalLogSuffix

      public static void setThreadLocalLogSuffix(@Nullable String sSuffix)
      Set the current thread local log suffix.
      Parameters:
      sSuffix - The suffix to set. May be null.
    • clearThreadLocals

      public static void clearThreadLocals()
      Clear the thread local log prefix and suffix.
    • runWithLogPrefixAndSuffix

      public static void runWithLogPrefixAndSuffix(@Nullable String sPrefix, @Nullable String sSuffix, @NonNull Runnable aRunnable)
      Run the passed runnable with the given prefix and suffix set as thread local.
      Parameters:
      sPrefix - The prefix to set. May be null.
      sSuffix - The suffix to set. May be null.
      aRunnable - The runnable to execute. May not be null.
    • callWithLogPrefixAndSuffix

      public static <T> T callWithLogPrefixAndSuffix(@Nullable String sPrefix, @Nullable String sSuffix, @NonNull Callable<T> aCallable) throws Exception
      Run the passed callable with the given prefix and suffix set as thread local.
      Type Parameters:
      T - The return type of the callable.
      Parameters:
      sPrefix - The prefix to set. May be null.
      sSuffix - The suffix to set. May be null.
      aCallable - The callable to execute. May not be null.
      Returns:
      The result of the callable.
      Throws:
      Exception - If the callable throws an exception.