Class SelenideLogger


  • @ParametersAreNonnullByDefault
    public class SelenideLogger
    extends java.lang.Object
    Logs 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 void addListener​(java.lang.String name, LogEventListener listener)
      Add a listener (to the current thread).
      static SelenideLog beginStep​(java.lang.String source, java.lang.String subject)  
      static SelenideLog beginStep​(java.lang.String source, java.lang.String methodName, java.lang.Object... args)  
      static void commitStep​(SelenideLog log, LogEvent.EventStatus status)  
      static void commitStep​(SelenideLog log, java.lang.Throwable error)  
      static <T> T get​(java.lang.String source, java.lang.String subject, java.util.function.Supplier<T> supplier)  
      static boolean hasListener​(java.lang.String name)
      If listener with given name is bound (added) to the current thread.
      static void removeAllListeners()  
      static <T extends LogEventListener>
      T
      removeListener​(java.lang.String name)
      Remove listener (from the current thread).
      static void run​(java.lang.String source, java.lang.String subject, java.lang.Runnable runnable)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • listeners

        protected static final java.lang.ThreadLocal<java.util.Map<java.lang.String,​LogEventListener>> listeners
    • Constructor Detail

      • SelenideLogger

        public SelenideLogger()
    • 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 method removeListener(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)
      • 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 method addListener(String, LogEventListener)
        Returns:
        the listener being removed
      • removeAllListeners

        public static void removeAllListeners()