Package co.arago.hiro.client.util
Class HttpLogger
- java.lang.Object
-
- co.arago.hiro.client.util.HttpLogger
-
public class HttpLogger extends java.lang.ObjectThis handles logging of HttpRequests and HttpResults.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<java.lang.String>filterA list of paths from an URI.protected booleanlogBodyprotected intmaxBinaryLength
-
Constructor Summary
Constructors Constructor Description HttpLogger(int maxBinaryLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanactive()voidaddFilter(java.net.URI uri)protected booleanfilterMatch(java.net.URI uri)intgetMaxBinaryLength()voidlogRequest(java.net.http.HttpRequest httpRequest, java.lang.Object body)Log a request from the data inside HttpRequest.voidlogResponseBody(java.net.http.HttpResponse<?> httpResponse, java.lang.Object body)Log a response from the data inside HttpResponse.voidlogResponseHeaders(java.net.http.HttpResponse<?> httpResponse)Log a response from the data inside HttpResponse.protected java.lang.StringprocessHeaderField(java.lang.String key, java.util.List<java.lang.String> value)Hide critical data from header loggingvoidremoveFilter(java.net.URI uri)voidsetLogBody(boolean logBody)Enable or disable logging of bodies.voidsetMaxBinaryLength(int maxBinaryLength)Max length to log for binary data
-
-
-
Method Detail
-
addFilter
public void addFilter(java.net.URI uri)
-
removeFilter
public void removeFilter(java.net.URI uri)
-
filterMatch
protected boolean filterMatch(java.net.URI uri)
-
setLogBody
public void setLogBody(boolean logBody)
Enable or disable logging of bodies. The values in thefilteroverride this.- Parameters:
logBody- The flag to set
-
getMaxBinaryLength
public int getMaxBinaryLength()
-
setMaxBinaryLength
public void setMaxBinaryLength(int maxBinaryLength)
Max length to log for binary data- Parameters:
maxBinaryLength- Length in bytes
-
active
public boolean active()
- Returns:
- Return true when the logger is logging
-
processHeaderField
protected java.lang.String processHeaderField(java.lang.String key, java.util.List<java.lang.String> value)Hide critical data from header logging- Parameters:
key- Header namevalue- Value of header- Returns:
- A secure string representation of the value of the header field.
-
logRequest
public void logRequest(java.net.http.HttpRequest httpRequest, java.lang.Object body)Log a request from the data inside HttpRequest.- Parameters:
httpRequest- The httpRequest to log.body- The body of the httpRequest.
-
logResponseHeaders
public void logResponseHeaders(java.net.http.HttpResponse<?> httpResponse)
Log a response from the data inside HttpResponse.- Parameters:
httpResponse- The httpResponse to log.
-
logResponseBody
public void logResponseBody(java.net.http.HttpResponse<?> httpResponse, java.lang.Object body)Log a response from the data inside HttpResponse.- Parameters:
httpResponse- The httpResponse to log.body- The body of the httpResponse.
-
-