Documentation ¶
Index ¶
- type CloudWatchLogger
- func (c *CloudWatchLogger) Close(correlationId string) error
- func (c *CloudWatchLogger) Configure(config *cconf.ConfigParams)
- func (c *CloudWatchLogger) IsOpen() bool
- func (c *CloudWatchLogger) Open(correlationId string) error
- func (c *CloudWatchLogger) Save(messages []*clog.LogMessage) error
- func (c *CloudWatchLogger) SetReferences(references cref.IReferences)
- func (c *CloudWatchLogger) Write(level int, correlationId string, ex error, message string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudWatchLogger ¶
type CloudWatchLogger struct { *clog.CachedLogger // contains filtered or unexported fields }
Logger that writes log messages to AWS Cloud Watch Log.
### Configuration parameters ###
- stream: (optional) Cloud Watch Log stream (default: context name) - group: (optional) Cloud Watch Log group (default: context instance ID or hostname) - connections:
- discovery_key: (optional) a key to retrieve the connection from IDiscovery
- region: (optional) AWS region
- credentials:
- store_key: (optional) a key to retrieve the credentials from ICredentialStore
- access_id: AWS access/client id
- access_key: AWS access/client id
- options:
- interval: interval in milliseconds to save current counters measurements (default: 5 mins)
- reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)
### References ###
- \*:context-info:\*:\*:1.0 (optional) ContextInfo to detect the context id and specify counters source - \*:discovery:\*:\*:1.0 (optional) IDiscovery services to resolve connections - \*:credential-store:\*:\*:1.0 (optional) Credential stores to resolve credentials
See Counter (in the Pip.Services components package) See CachedCounters (in the Pip.Services components package) See CompositeLogger (in the Pip.Services components package)
### Example ###
logger := NewLogger(); logger.Config(NewConfigParamsFromTuples( "stream", "mystream", "group", "mygroup", "connection.region", "us-east-1", "connection.access_id", "XXXXXXXXXXX", "connection.access_key", "XXXXXXXXXXX", )); logger.SetReferences(NewReferencesFromTuples( NewDescriptor("pip-services", "logger", "console", "default", "1.0"), NewConsoleLogger() )); err:= logger.Open("123") ... logger.SetLevel(Debug); logger.Error("123", ex, "Error occured: %s", ex.Message); logger.Debug("123", "Everything is OK.");
func NewCloudWatchLogger ¶
func NewCloudWatchLogger() *CloudWatchLogger
Creates a new instance of this logger.
func (*CloudWatchLogger) Close ¶
func (c *CloudWatchLogger) Close(correlationId string) error
Closes component and frees used resources.
- correlationId (optional) transaction id to trace execution through call chain.
- Returns error or nil no errors occured.
func (*CloudWatchLogger) Configure ¶
func (c *CloudWatchLogger) Configure(config *cconf.ConfigParams)
Configure method configures component by passing configuration parameters.
- config configuration parameters to be set.
func (*CloudWatchLogger) IsOpen ¶
func (c *CloudWatchLogger) IsOpen() bool
Checks if the component is opened. Returns true if the component has been opened and false otherwise.
func (*CloudWatchLogger) Open ¶
func (c *CloudWatchLogger) Open(correlationId string) error
Opens the component.
- correlationId (optional) transaction id to trace execution through call chain.
- Returns error or nil no errors occured.
func (*CloudWatchLogger) Save ¶
func (c *CloudWatchLogger) Save(messages []*clog.LogMessage) error
Saves log messages from the cache.
- messages a list with log messages
- Returns error or nil for success.
func (*CloudWatchLogger) SetReferences ¶
func (c *CloudWatchLogger) SetReferences(references cref.IReferences)
SetReferences method sets references to dependent components.
- references references to locate the component dependencies.
See IReferences (in the Pip.Services commons package)
func (*CloudWatchLogger) Write ¶
func (c *CloudWatchLogger) Write(level int, correlationId string, ex error, message string)
Writes a log message to the logger destination.
- level a log level.
- correlationId (optional) transaction id to trace execution through call chain.
- error an error object associated with this message.
- message a human-readable message to log.