Class LoggingContext


  • public class LoggingContext
    extends java.lang.Object
    Logging context holds thread-local context for logging and converts SaveLogRQ to multipart HTTP request to ReportPortal Basic flow: After start some test item (suite/test/step) context should be initialized with observable of item ID and ReportPortal client. Before actual finish of test item, context should be closed/completed. Context consists of Flowable with buffering back-pressure strategy to be able to batch incoming log messages into one request
    See Also:
    init(Maybe)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static LoggingContext context()
      Return current logging context attached to the current thread.
      static LoggingContext dispose()
      Disposes current logging context
      void emit​(io.reactivex.Maybe<java.lang.String> logItemUuid, java.util.function.Function<java.lang.String,​SaveLogRQ> logSupplier)
      Emits log.
      void emit​(java.util.function.Function<java.lang.String,​SaveLogRQ> logSupplier)
      Emits log.
      static LoggingContext init​(io.reactivex.Maybe<java.lang.String> itemUuid)
      Initializes new logging context and attaches it to current thread
      • Methods inherited from class java.lang.Object

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

      • context

        @Nullable
        public static LoggingContext context()
        Return current logging context attached to the current thread. Return parent thread context if self context not found. And return 'null' if nothing was found at all.
        Returns:
        current or parent logging context or 'null'
      • init

        @Nonnull
        public static LoggingContext init​(@Nonnull
                                          io.reactivex.Maybe<java.lang.String> itemUuid)
        Initializes new logging context and attaches it to current thread
        Parameters:
        itemUuid - a Test Item UUID
        Returns:
        New Logging Context
      • dispose

        @Nullable
        public static LoggingContext dispose()
        Disposes current logging context
        Returns:
        Disposed Logging Context or 'null' if no context was found
      • emit

        public void emit​(@Nonnull
                         io.reactivex.Maybe<java.lang.String> logItemUuid,
                         @Nonnull
                         java.util.function.Function<java.lang.String,​SaveLogRQ> logSupplier)
        Emits log. Basically, put it into processing pipeline
        Parameters:
        logItemUuid - Test Item ID promise
        logSupplier - Log Message Factory. Key if the function is actual test item ID
      • emit

        public void emit​(@Nonnull
                         java.util.function.Function<java.lang.String,​SaveLogRQ> logSupplier)
        Emits log. Basically, put it into processing pipeline
        Parameters:
        logSupplier - Log Message Factory. Key if the function is actual test item ID