Package org.cyclos.impl.logging
Class LogContext
- java.lang.Object
-
- org.cyclos.impl.logging.LogContext
-
public class LogContext extends Object
Contains log information about a service to be invoked.
A service could be: a web-rpc service method, a custom web service, an external redirect callback (custom operation) or an inbound sms.
The information contained in this context will be logged though theLoggingHandler's implementation.
Note: if any ofServiceLogParamsorLogConfigurationare null it means a log entry must not be generated, all methods take this into account being safe to call any of them even in that case. Example: ifServiceLogParamsis null you can call thesetError(Throwable)method directly (it will be a noop).
-
-
Constructor Summary
Constructors Constructor Description LogContext(LoggingHandler loggingHandler, JsonConverter jsonConverter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LogContextempty()voidlogService()voidsetError(Throwable error)Sets the error thrown by the service's execution.
Noop iflogParamsorlogConfigurationare null.LogContextsetLogConfiguration(LogConfiguration logConfiguration)Sets theLogConfigurationand returns the same instanceLogContextsetResult(Pair<Object,com.fasterxml.jackson.databind.JsonNode> resultPair)Sets the result of a service's execution and returns the same instance.
Noop iflogParamsorlogConfigurationare null.LogContextsetServiceLogParams(ServiceLogParams logParams)Sets theServiceLogParamsand returns the same instance.voidsetSkipSuccess(boolean skipSuccess)LogContextsetTimeTaken(long timeTaken)Sets the time taken by the execution and returns the same instance.
Noop iflogParamsorlogConfigurationare null.LogContextsetWrite(boolean isWrite)Sets this invocation as having a write to the database and returns the same instance.
-
-
-
Constructor Detail
-
LogContext
public LogContext(LoggingHandler loggingHandler, JsonConverter jsonConverter)
-
-
Method Detail
-
empty
public static LogContext empty()
-
logService
public void logService()
-
setError
public void setError(Throwable error)
Sets the error thrown by the service's execution.
Noop iflogParamsorlogConfigurationare null.
-
setLogConfiguration
public LogContext setLogConfiguration(LogConfiguration logConfiguration)
Sets theLogConfigurationand returns the same instance
-
setResult
public LogContext setResult(Pair<Object,com.fasterxml.jackson.databind.JsonNode> resultPair)
Sets the result of a service's execution and returns the same instance.
Noop iflogParamsorlogConfigurationare null.
-
setServiceLogParams
public LogContext setServiceLogParams(ServiceLogParams logParams)
Sets theServiceLogParamsand returns the same instance.
-
setSkipSuccess
public void setSkipSuccess(boolean skipSuccess)
-
setTimeTaken
public LogContext setTimeTaken(long timeTaken)
Sets the time taken by the execution and returns the same instance.
Noop iflogParamsorlogConfigurationare null.
-
setWrite
public LogContext setWrite(boolean isWrite)
Sets this invocation as having a write to the database and returns the same instance.
-
-