Package com.codeborne.selenide.logevents
Class SelenideLogger
- java.lang.Object
-
- com.codeborne.selenide.logevents.SelenideLogger
-
@ParametersAreNonnullByDefault public class SelenideLogger extends java.lang.ObjectLogs Selenide test steps and notifies all registered LogEventListener about it
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.ThreadLocal<java.util.Map<java.lang.String,LogEventListener>>listeners
-
Constructor Summary
Constructors Constructor Description SelenideLogger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddListener(java.lang.String name, LogEventListener listener)Add a listener (to the current thread).static SelenideLogbeginStep(java.lang.String source, java.lang.String subject)static SelenideLogbeginStep(java.lang.String source, java.lang.String methodName, java.lang.Object... args)static voidcommitStep(SelenideLog log, LogEvent.EventStatus status)static voidcommitStep(SelenideLog log, java.lang.Throwable error)static <T> Tget(java.lang.String source, java.lang.String subject, java.util.function.Supplier<T> supplier)static booleanhasListener(java.lang.String name)If listener with given name is bound (added) to the current thread.static voidremoveAllListeners()static <T extends LogEventListener>
TremoveListener(java.lang.String name)Remove listener (from the current thread).static voidrun(java.lang.String source, java.lang.String subject, java.lang.Runnable runnable)
-
-
-
Field Detail
-
listeners
protected static final java.lang.ThreadLocal<java.util.Map<java.lang.String,LogEventListener>> listeners
-
-
Method Detail
-
addListener
public static void addListener(java.lang.String name, LogEventListener listener)Add a listener (to the current thread).- Parameters:
name- unique name of this listener (per thread). Can be used later to remove listener using methodremoveListener(String)listener- event listener
-
beginStep
@CheckReturnValue @Nonnull public static SelenideLog beginStep(java.lang.String source, java.lang.String methodName, @Nullable java.lang.Object... args)
-
beginStep
@CheckReturnValue @Nonnull public static SelenideLog beginStep(java.lang.String source, java.lang.String subject)
-
commitStep
public static void commitStep(SelenideLog log, java.lang.Throwable error)
-
commitStep
public static void commitStep(SelenideLog log, LogEvent.EventStatus status)
-
run
public static void run(java.lang.String source, java.lang.String subject, java.lang.Runnable runnable)
-
get
public static <T> T get(java.lang.String source, @Nullable java.lang.String subject, java.util.function.Supplier<T> supplier)
-
removeListener
@Nullable public static <T extends LogEventListener> T removeListener(java.lang.String name)
Remove listener (from the current thread).- Type Parameters:
T- class of listener to be returned- Parameters:
name- unique name of listener added by methodaddListener(String, LogEventListener)- Returns:
- the listener being removed
-
removeAllListeners
public static void removeAllListeners()
-
hasListener
public static boolean hasListener(java.lang.String name)
If listener with given name is bound (added) to the current thread.- Parameters:
name- unique name of listener added by methodaddListener(String, LogEventListener)- Returns:
- true if method
addListener(String, LogEventListener)with corresponding name has been called in current thread.
-
-