Package com.helger.phase4.logging
Class Phase4LogCustomizer
java.lang.Object
com.helger.phase4.logging.Phase4LogCustomizer
The logging customizer for the phase4 library.
- Since:
- 3.1.0-beta3
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcallWithLogPrefixAndSuffix(String sPrefix, String sSuffix, Callable<T> aCallable) Run the passed callable with the given prefix and suffix set as thread local.static voidClear the thread local log prefix and suffix.static StringGet the current thread local log prefix.static StringGet the current thread local log suffix.static voidrunWithLogPrefixAndSuffix(String sPrefix, String sSuffix, Runnable aRunnable) Run the passed runnable with the given prefix and suffix set as thread local.static voidsetThreadLocalLogPrefix(String sPrefix) Set the current thread local log prefix.static voidsetThreadLocalLogSuffix(String sSuffix) Set the current thread local log suffix.
-
Method Details
-
getThreadLocalLogPrefix
Get the current thread local log prefix.- Returns:
- The current thread local log prefix. May be
null.
-
setThreadLocalLogPrefix
Set the current thread local log prefix.- Parameters:
sPrefix- The prefix to set. May benull.
-
getThreadLocalLogSuffix
Get the current thread local log suffix.- Returns:
- The current thread local log suffix. May be
null.
-
setThreadLocalLogSuffix
Set the current thread local log suffix.- Parameters:
sSuffix- The suffix to set. May benull.
-
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 benull.sSuffix- The suffix to set. May benull.aRunnable- The runnable to execute. May not benull.
-
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 benull.sSuffix- The suffix to set. May benull.aCallable- The callable to execute. May not benull.- Returns:
- The result of the callable.
- Throws:
Exception- If the callable throws an exception.
-