public abstract class AbstractLoggingServiceMonitor extends AbstractServiceMonitor
Modifier and Type | Field and Description |
---|---|
protected boolean |
cacheHit |
protected Map<String,String> |
context |
protected String |
correlationId |
protected Long |
endTime |
protected boolean |
error |
protected String |
errorMessage |
protected Long |
executionTime |
protected boolean |
failure |
protected Exception |
failureException |
protected String |
failureReason |
protected Object[] |
parameters |
protected long |
startTime |
Constructor and Description |
---|
AbstractLoggingServiceMonitor(IService service,
boolean enableLog,
boolean useThreadLocal) |
Modifier and Type | Method and Description |
---|---|
void |
beginCall(Object... parameters)
Notify of the beginning of a call to a service.
|
void |
cacheHit()
Reports that a cache system was used instead of performing the actual
call.
|
void |
context(String name,
String value) |
void |
correlationId(String correlationId) |
void |
endCall()
Notify the end of a call to a service.
|
void |
error(String message)
Reports an error : the call has succeed but returns an error (with data).
|
void |
executionTime(long timeMillis)
Manually set the execution time.
|
void |
failure(String reason)
Reports a failure : the call has failed completely
|
void |
failure(String reason,
Exception e)
Reports a failure : the call has failed completely with exception e.
|
protected org.slf4j.Logger |
getLogger() |
protected String |
getLogMessage()
Returns the log message (at the end of the call).
|
long |
getStartTime() |
void |
setLogFormat(String messageFormat)
Set the log message format for this monitor instance, based on :
http://commons.apache.org/lang/api-release/org/apache/commons/lang3/text/
StrSubstitutor.html
Example :
${correlationId}|${group}|${name}|${responseTime}|${cache}|${status}|${statusMessage}
Available variables :
group
name
responseTime
cache
failure
failureReason
failureException
error
errorMessage
correlationId
status : SUCCESS/FAILURE/ERROR
statusMessage : failure or error message
Any additional context values
|
void |
setLogger(org.slf4j.Logger l)
Set the logger to use for this service call.
|
void |
setMessageFormat(String messageFormat)
Deprecated.
Use
setLogFormat(String) instead |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
nestedCall
protected boolean cacheHit
protected String correlationId
protected Long endTime
protected boolean error
protected String errorMessage
protected Long executionTime
protected boolean failure
protected Exception failureException
protected String failureReason
protected Object[] parameters
protected long startTime
public AbstractLoggingServiceMonitor(IService service, boolean enableLog, boolean useThreadLocal)
public void beginCall(Object... parameters)
IServiceMonitor
beginCall
in interface IServiceMonitor
beginCall
in class AbstractServiceMonitor
parameters
- operation parameterspublic void cacheHit()
IServiceMonitor
public void correlationId(String correlationId)
public void endCall()
IServiceMonitor
endCall
in interface IServiceMonitor
endCall
in class AbstractServiceMonitor
public void error(String message)
IServiceMonitor
public void executionTime(long timeMillis)
IServiceMonitor
public void failure(String reason)
IServiceMonitor
public void failure(String reason, Exception e)
IServiceMonitor
protected org.slf4j.Logger getLogger()
protected String getLogMessage()
This method can be overridden for very complex messages.
public long getStartTime()
public void setLogFormat(String messageFormat)
IServiceMonitor
Example :
${correlationId}|${group}|${name}|${responseTime}|${cache}|${status}|${statusMessage}
Available variables :
public void setLogger(org.slf4j.Logger l)
IServiceMonitor
@Deprecated public void setMessageFormat(String messageFormat)
setLogFormat(String)
instead
Example :
${correlationId}|${group}|${name}|${responseTime}|${cache}|${status}|${statusMessage}
Available variables :
messageFormat
- Copyright © 2010–2016. All rights reserved.