io.vrap.rmf.base.client.http.InternalLoggerMiddleware Maven / Gradle / Ivy
Show all versions of rmf-java-base Show documentation
package io.vrap.rmf.base.client.http;
import java.util.Map;
import io.vrap.rmf.base.client.ApiHttpHeaders;
import org.slf4j.event.Level;
/**
* Middleware instrumenting the {@link InternalLogger}
*
* Responses are logged by default with {@link Level#INFO}.
* In case of an {@link ApiHttpHeaders#X_DEPRECATION_NOTICE deprecation} header the notice will be logged with {@link Level#INFO}
* Any exception will be logged with {@link Level#ERROR}
*
* The response, deprecation and error logger levels are configurable. Additionally, a map can be provided with the key a throwable type class
* and the value of the log level the exception should be logged with
*
* The middleware logs with debug also the request and the whole response including headers. With trace level the request and response will
* be logged pretty printed.
*
* All log events are written as lambda function to avoid rendering the message if the respective level is not enabled.
*/
public interface InternalLoggerMiddleware extends Middleware {
static InternalLoggerMiddleware of(final InternalLoggerFactory internalLoggerFactory) {
return new InternalLoggerMiddlewareImpl(internalLoggerFactory);
}
static InternalLoggerMiddleware of(final InternalLoggerFactory internalLoggerFactory, final Level responseLogEvent,
final Level deprecationLogEvent) {
return new InternalLoggerMiddlewareImpl(internalLoggerFactory, responseLogEvent, deprecationLogEvent);
}
static InternalLoggerMiddleware of(final InternalLoggerFactory internalLoggerFactory, final Level responseLogEvent,
final Level deprecationLogEvent, final Level defaultExceptionLogEvent,
final Map, Level> exceptionLogEvents) {
return new InternalLoggerMiddlewareImpl(internalLoggerFactory, responseLogEvent, deprecationLogEvent,
defaultExceptionLogEvent, exceptionLogEvents);
}
static InternalLoggerMiddleware of(final InternalLoggerFactory internalLoggerFactory, final Level responseLogEvent,
final Level deprecationLogEvent, final Level defaultExceptionLogEvent,
final Map, Level> exceptionLogEvents,
final ResponseLogFormatter responseLogFormatter, final ErrorLogFormatter errorLogFormatter) {
return new InternalLoggerMiddlewareImpl(internalLoggerFactory, responseLogEvent, deprecationLogEvent,
defaultExceptionLogEvent, exceptionLogEvents, responseLogFormatter, errorLogFormatter);
}
}