@API(status=STABLE) public final class JsonHttpLogFormatter extends Object implements StructuredHttpLogFormatter
HttpLogFormatter that produces JSON objects. It can be augmented with composition:
public class CustomsFormatter implements HttpLogFormatter {
private final JsonHttpLogFormatter delegate;
public CustomsFormatter(ObjectMapper mapper) {
this.delegate = new JsonHttpLogFormatter(mapper);
}
public String format(Precorrelation precorrelation, HttpRequest request) throws IOException {
Map<String, Object> content = delegate.prepare(precorrelation, request);
// modify request here
return delegate.format(content);
}
public String format(Correlation correlation, HttpResponse response) throws IOException {
Map<String, Object> content = delegate.prepare(correlation, response);
// modify response here
return delegate.format(content);
}
}
| Constructor and Description |
|---|
JsonHttpLogFormatter() |
JsonHttpLogFormatter(com.fasterxml.jackson.databind.ObjectMapper mapper) |
| Modifier and Type | Method and Description |
|---|---|
String |
format(Map<String,Object> content) |
Optional<Object> |
prepareBody(HttpMessage message) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitformat, format, prepare, prepare, prepareHeaders, preparePortpublic JsonHttpLogFormatter()
public JsonHttpLogFormatter(com.fasterxml.jackson.databind.ObjectMapper mapper)
public Optional<Object> prepareBody(HttpMessage message) throws IOException
prepareBody in interface StructuredHttpLogFormatterIOExceptionpublic String format(Map<String,Object> content) throws IOException
format in interface StructuredHttpLogFormatterIOExceptionCopyright © 2015–2021 Zalando SE. All rights reserved.