Class LogTracer
java.lang.Object
org.pipservices3.components.trace.LogTracer
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable,org.pipservices3.commons.refer.IReferenceable,ITracer
public class LogTracer
extends Object
implements org.pipservices3.commons.config.IConfigurable, org.pipservices3.commons.refer.IReferenceable, ITracer
Tracer that dumps recorded traces to logger.
### Configuration parameters ###
- - options:
- - log_level: log level to record traces (default: debug)
- *:logger:*:*:1.0 (optional)
ILoggercomponents to dump the captured counters - *:context-info:*:*:1.0 (optional)
ContextInfoto detect the context id and specify counters source
- See Also:
-
ITracerCachedCounters### Example ###LogTracer tracer = new LogTracer(); tracer.setReferences(References.fromTuples( new Descriptor("pip-services", "logger", "console", "default", "1.0"), new ConsoleLogger() )); TraceTiming timing = trcer.beginTrace("123", "mycomponent", "mymethod"); try { ... timing.endTrace(); } catch(err) { timing.endFailure(err); }
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbeginTrace(String correlationId, String component, String operation) Begings recording an operation tracevoidconfigure(org.pipservices3.commons.config.ConfigParams config) Configures component by passing configuration parameters.voidRecords an operation failure with its name, duration and errorvoidsetReferences(org.pipservices3.commons.refer.IReferences references) Sets references to dependent components.voidRecords an operation trace with its name and duration
-
Constructor Details
-
LogTracer
public LogTracer()
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config) throws org.pipservices3.commons.errors.ConfigException Configures component by passing configuration parameters.- Specified by:
configurein interfaceorg.pipservices3.commons.config.IConfigurable- Parameters:
config- configuration parameters to be set.- Throws:
org.pipservices3.commons.errors.ConfigException
-
setReferences
public void setReferences(org.pipservices3.commons.refer.IReferences references) Sets references to dependent components.- Specified by:
setReferencesin interfaceorg.pipservices3.commons.refer.IReferenceable- Parameters:
references- references to locate the component dependencies.- Throws:
org.pipservices3.commons.refer.ReferenceExceptionorg.pipservices3.commons.errors.ConfigException
-
trace
Records an operation trace with its name and duration -
failure
public void failure(String correlationId, String component, String operation, Exception error, long duration) Records an operation failure with its name, duration and error- Specified by:
failurein interfaceITracer- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.component- a name of called componentoperation- a name of the executed operation.error- an error object associated with this trace.duration- execution duration in milliseconds.
-
beginTrace
Begings recording an operation trace- Specified by:
beginTracein interfaceITracer- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.component- a name of called componentoperation- a name of the executed operation.
-