Documentation ¶
Index ¶
- type ElasticSearchLogger
- func (c *ElasticSearchLogger) Close(correlationId string) (err error)
- func (c *ElasticSearchLogger) Configure(config *cconf.ConfigParams)
- func (c *ElasticSearchLogger) IsOpen() bool
- func (c *ElasticSearchLogger) Open(correlationId string) (err error)
- func (c *ElasticSearchLogger) Save(messages []*clog.LogMessage) (err error)
- func (c *ElasticSearchLogger) SetReferences(references cref.IReferences)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElasticSearchLogger ¶
type ElasticSearchLogger struct { *clog.CachedLogger // contains filtered or unexported fields }
ElasticSearchLogger is logger that dumps execution logs to ElasticSearch service. ElasticSearch is a popular search index. It is often used to store and index execution logs by itself or as a part of ELK (ElasticSearch - Logstash - Kibana) stack.
Authentication is not supported in this version.
Configuration parameters:
- level: maximum log level to capture - source: source (context) name - connection(s):
- discovery_key: (optional) a key to retrieve the connection from IDiscovery
- protocol: connection protocol: http or https
- host: host name or IP address
- port: port int
- uri: resource URI or connection string with all parameters in it
- options:
- interval: interval in milliseconds to save log messages (default: 10 seconds)
- max_cache_size: maximum int of messages stored in this cache (default: 100)
- index: ElasticSearch index name (default: "log")
- daily: true to create a new index every day by adding date suffix to the index name (default: false)
- reconnect: reconnect timeout in milliseconds (default: 60 sec)
- timeout: invocation timeout in milliseconds (default: 30 sec)
- max_retries: maximum int of retries (default: 3)
- index_message: true to enable indexing for message object (default: false)
References:
- *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source - *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connection
Example:
logger := NewElasticSearchLogger(); logger.Configure(cconf.NewConfigParamsFromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", "9200" )); logger.Open("123") logger.Error("123", ex, "Error occured: %s", ex.message); logger.Debug("123", "Everything is OK.");
func NewElasticSearchLogger ¶
func NewElasticSearchLogger() *ElasticSearchLogger
NewElasticSearchLogger method creates a new instance of the logger. Retruns *ElasticSearchLogger pointer on new ElasticSearchLogger
func (*ElasticSearchLogger) Close ¶
func (c *ElasticSearchLogger) Close(correlationId string) (err error)
Close method are closes component and frees used resources. Parameters:
- correlationId string (optional) transaction id to trace execution through call chain.
Returns error or nil, if no errors occured.
func (*ElasticSearchLogger) Configure ¶
func (c *ElasticSearchLogger) Configure(config *cconf.ConfigParams)
Configure are configures component by passing configuration parameters. Parameters:
- config *cconf.ConfigParams configuration parameters to be set.
func (*ElasticSearchLogger) IsOpen ¶
func (c *ElasticSearchLogger) IsOpen() bool
IsOpen method are checks if the component is opened. Returns true if the component has been opened and false otherwise.
func (*ElasticSearchLogger) Open ¶
func (c *ElasticSearchLogger) Open(correlationId string) (err error)
Open method are ppens the component. Parameters:
- correlationId string (optional) transaction id to trace execution through call chain.
Returns error or nil, if no errors occured.
func (*ElasticSearchLogger) Save ¶
func (c *ElasticSearchLogger) Save(messages []*clog.LogMessage) (err error)
Save method are saves log messages from the cache. Parameters:
- messages []*clog.LogMessage a list with log messages
Retruns error or nil for success.
func (*ElasticSearchLogger) SetReferences ¶
func (c *ElasticSearchLogger) SetReferences(references cref.IReferences)
SetReferences method are sets references to dependent components. Parameters:
- references cref.IReferences references to locate the component dependencies.