/** * Returns a composed listener that calls this listener first and then the specified one. */ default RequestLogListener andThen(RequestLogListener other) { Objects.requireNonNull(other, "other"); final RequestLogListener first = this; final RequestLogListener second = other; return log -> { RequestLogListenerInvoker.invokeOnRequestLog(first, log); second.onRequestLog(log); }; } }
/** * Invokes {@link RequestLogListener#onRequestLog(RequestLog)}. */ public static void invokeOnRequestLog(RequestLogListener listener, RequestLog log) { try (SafeCloseable ignored = log.context().push()) { listener.onRequestLog(log); } catch (Throwable e) { logger.warn("onRequestLog() failed with an exception:", e); } }