Documentation
¶
Overview ¶
Package cloudlog provides a CloudLog client library
Index ¶
- Constants
- Variables
- func ConvertToTimestamp(value interface{}) interface{}
- func IsEventEncodingError(err error) (ok bool, event interface{})
- type AutomaticEventEncoder
- type Client
- type CloudLog
- type Config
- type Event
- type EventEncoder
- type EventEncodingError
- type MarshalError
- type SimpleEventEncoder
- type StructEncoder
Constants ¶
const DefaultTagName = "cloudlog"
DefaultTagName defines the default tag name to use
Variables ¶
var ( // ErrIndexNotDefined indicates that the target index has not been defined ErrIndexNotDefined = errors.New("Target index is not defined") )
Functions ¶
func ConvertToTimestamp ¶
func ConvertToTimestamp(value interface{}) interface{}
ConvertToTimestamp takes an empty interface and tries to convert the value to a timestamp as expected by CloudLog (Unix millisecond timestamp). Besides being a no-op for int64 values, this function is able to convert time.Time values correctly.
If conversion is not possible this function returns the original value.
func IsEventEncodingError ¶
IsEventEncodingError checks if a supplied error is an EventEncodingError and returns a boolean flag and the event that caused the error
Types ¶
type AutomaticEventEncoder ¶
type AutomaticEventEncoder struct {
Encoders []EventEncoder
}
AutomaticEventEncoder tries to find the right encoder for the given input
func NewAutomaticEventEncoder ¶
func NewAutomaticEventEncoder() *AutomaticEventEncoder
NewAutomaticEventEncoder returns a new encoder that supports all available encoders
func (*AutomaticEventEncoder) EncodeEvent ¶
func (e *AutomaticEventEncoder) EncodeEvent(event interface{}) (map[string]interface{}, error)
EncodeEvent encodes the given event
type CloudLog ¶
type CloudLog struct {
// contains filtered or unexported fields
}
CloudLog is the CloudLog object to send logs
func NewCloudLog ¶
NewCloudLog initializes a new CloudLog instance with the default config
func NewCloudlogWithConfig ¶
NewCloudlogWithConfig initializes a new CloudLog instance using the provided config
func (*CloudLog) PushEvents ¶
PushEvents sends the supplied events to CloudLog
type Config ¶
type Config struct { Hostname string Encoder EventEncoder Client Client }
Config is the go-cloudlog config
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a new config with default values
type Event ¶
type Event interface { // Encode encodes the given event to a map[string]interface{} Encode() map[string]interface{} }
Event defines the interface events may optionally implement to provide their own encoding logic
type EventEncoder ¶
type EventEncoder interface { // EncodeEvent encodes the given event EncodeEvent(event interface{}) (map[string]interface{}, error) }
EventEncoder defines the interface for encoding events
type EventEncodingError ¶
type EventEncodingError struct { Message string Event interface{} }
EventEncodingError indicates that an event could not be encoded
func NewUnsupportedEventType ¶
func NewUnsupportedEventType(event interface{}) *EventEncodingError
NewUnsupportedEventType constructs a new EventEncodingError that indicates that the supplied event type is unsupported
func (*EventEncodingError) Error ¶
func (e *EventEncodingError) Error() string
type MarshalError ¶
type MarshalError struct { // EventMap contains the events data map EventMap map[string]interface{} // Parent contains the parent error Parent error }
MarshalError represents a marshalling error
func NewMarshalError ¶
func NewMarshalError(eventMap map[string]interface{}, parent error) *MarshalError
NewMarshalError returns a new MarshalError
func (*MarshalError) Error ¶
func (e *MarshalError) Error() string
func (*MarshalError) WrappedErrors ¶
func (e *MarshalError) WrappedErrors() []error
WrappedErrors returns the wrapped parent error
type SimpleEventEncoder ¶
type SimpleEventEncoder struct { }
SimpleEventEncoder implements a simple event encoder This encoder only supports map[string]interface{}, string and []byte events. A more sophisticated encoder providing support for encoding structs as well is available from the structencoder sub-package.
func (*SimpleEventEncoder) EncodeEvent ¶
func (e *SimpleEventEncoder) EncodeEvent(event interface{}) (map[string]interface{}, error)
EncodeEvent encodes the given event
type StructEncoder ¶
type StructEncoder struct{}
StructEncoder encodes a struct
func NewStructEncoder ¶
func NewStructEncoder() (*StructEncoder, error)
NewStructEncoder returns a new encoder that supports structs
func (*StructEncoder) EncodeEvent ¶
func (e *StructEncoder) EncodeEvent(event interface{}) (m map[string]interface{}, err error)
EncodeEvent encodes the given event