Documentation ¶
Index ¶
- type Agent
- type Dispatcher
- type ECS
- type Error
- type HTTP
- type Log
- type LogLevel
- type LogMessage
- func (msg *LogMessage) Marshall() ([]byte, error)
- func (msg LogMessage) WithAgent(agent Agent) LogMessage
- func (msg LogMessage) WithError(err Error) LogMessage
- func (msg LogMessage) WithHTTP(httpInfo HTTP) LogMessage
- func (msg LogMessage) WithLabels(labels map[string]string) LogMessage
- func (msg LogMessage) WithLog(log Log) LogMessage
- func (msg LogMessage) WithMessage(message string) LogMessage
- func (msg LogMessage) WithTags(tags []string) LogMessage
- type Logger
- type Mock
- type MockDispatcher
- type MuxDispatcher
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct { Version string `json:"version,omitempty"` Name string `json:"name,omitempty"` ID string `json:"id,omitempty"` EphemeralID string `json:"ephemeral_id,omitempty"` }
Agent is the structure of an agent
func NewAgent ¶
func NewAgent() Agent
NewAgent creates a new Agent and properly initializes all required fields
func (Agent) WithEphemeralID ¶
WithEphemeralID sets the ephemeral id field and returns the agent itself
func (Agent) WithVersion ¶
WithVersion sets the version field and returns the agent itself
type Dispatcher ¶
type Dispatcher interface { Dispatch(msg LogMessage) error Add(loggers ...Logger) WithLogLevel(level LogLevel) Dispatcher }
Dispatcher is the common Log dispatcher interface
type ECS ¶
type ECS struct {
Version string `json:"version,omitempty"`
}
ECS is the structure of Meta-information specific to ECS
type Error ¶
type Error struct { Message string `json:"message,omitempty"` ID string `json:"id,omitempty"` Code string `json:"code,omitempty"` }
Error is the structure of an error These fields can represent errors of any kind. Use them for errors that happen while fetching events or in cases where the event itself contains an error.
func NewError ¶
func NewError() Error
NewError creates a new Error and properly initializes all required fields
func (Error) WithMessage ¶
WithMessage sets the message field and returns the error itself
type HTTP ¶
type HTTP struct { Version string `json:"version,omitempty"` Response Response `json:"response,omitempty"` Request Request `json:"request,omitempty"` }
HTTP is the structure of an http request and response Fields related to HTTP requests and responses.
func NewHTTP ¶
func NewHTTP() HTTP
NewHTTP creates a new HTTP and properly initializes all required fields
func (HTTP) WithRequest ¶
WithRequest sets the request object field and returns the http itself
func (HTTP) WithResponse ¶
WithResponse sets the response object field and returns the http itself
func (HTTP) WithVersion ¶
WithVersion sets the version field and returns the http itself
type Log ¶
type Log struct { Level string `json:"level,omitempty"` Original string `json:"original,omitempty"` Line uint32 `json:"line,omitempty"` Offset uint32 `json:"offset,omitempty"` // contains filtered or unexported fields }
Log is the structure of a Log event
func NewLog ¶
func NewLog() Log
NewLog creates a new Log and properly initializes all required fields
func (Log) WithOffset ¶
WithOffset sets the log offset field and returns the log itself
func (Log) WithOriginal ¶
WithOriginal sets the log original message field and returns the log itself
type LogLevel ¶
type LogLevel int
LogLevel defines the logging level as untyped int
const ( // ERROR defines the error log level as int value of 1 ERROR LogLevel = iota + 1 // WARNING defines the warning log level as int value of 2 WARNING // INFO defines the info log level as int value of 3 INFO // DEBUG defines the debug log level as int value of 4 DEBUG // TRACE defines the trace log level as int value of 5 TRACE )
type LogMessage ¶
type LogMessage struct { Timestamp strfmt.DateTime `json:"@timestamp,omitempty"` Tags []string `json:"tags,omitempty"` Labels map[string]string `json:"labels,omitempty"` Message string `json:"message,omitempty"` Agent Agent `json:"agent,omitempty"` Error Error `json:"error,omitempty"` HTTP HTTP `json:"http,omitempty"` Log Log `json:"log,omitempty"` ECS ECS `json:"ecs,omitempty"` }
LogMessage is the top-level structure The base set contains all fields which are on the top level. These fields are common across all types of events.
func NewLogMessage ¶
func NewLogMessage() LogMessage
NewLogMessage creates a new LogMessage and properly initializes all required fields
func (*LogMessage) Marshall ¶
func (msg *LogMessage) Marshall() ([]byte, error)
Marshall returns the json representation of a LogMessage
func (LogMessage) WithAgent ¶
func (msg LogMessage) WithAgent(agent Agent) LogMessage
WithAgent sets the agent object field and returns the message itself
func (LogMessage) WithError ¶
func (msg LogMessage) WithError(err Error) LogMessage
WithError sets the agent object field and returns the message itself
func (LogMessage) WithHTTP ¶
func (msg LogMessage) WithHTTP(httpInfo HTTP) LogMessage
WithHTTP sets the http object field and returns the message itself
func (LogMessage) WithLabels ¶
func (msg LogMessage) WithLabels(labels map[string]string) LogMessage
WithLabels sets the labels field and returns the message itself
func (LogMessage) WithLog ¶
func (msg LogMessage) WithLog(log Log) LogMessage
WithLog sets the log object field and returns the message itself
func (LogMessage) WithMessage ¶
func (msg LogMessage) WithMessage(message string) LogMessage
WithMessage sets the message field and returns the message itself
func (LogMessage) WithTags ¶
func (msg LogMessage) WithTags(tags []string) LogMessage
WithTags sets the tags field and returns the message itself
type Logger ¶
type Logger interface {
Log(msg LogMessage) error
}
Logger is the interface describing a loggers's behavior
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock logger to be used in tests
func (*Mock) GetLoggedMessages ¶
func (logger *Mock) GetLoggedMessages() []LogMessage
GetLoggedMessages returns a slice of all logged messages
func (*Mock) Log ¶
func (logger *Mock) Log(msg LogMessage) error
Log mocks logging used the mock logger implementation
type MockDispatcher ¶
type MockDispatcher struct {
// contains filtered or unexported fields
}
MockDispatcher is a mock log dispatcher to be used in tests
func NewMockDispatcher ¶
func NewMockDispatcher() *MockDispatcher
NewMockDispatcher creates a new mock log dispatcher to be used in testing
func (*MockDispatcher) Add ¶
func (ld *MockDispatcher) Add(loggers ...Logger)
Add is a dummy implementation for mocking
func (*MockDispatcher) Dispatch ¶
func (ld *MockDispatcher) Dispatch(msg LogMessage) error
Dispatch iterates over dispatcher loggers and logs the given message for each one of them
func (*MockDispatcher) GetDispatchedMessages ¶
func (ld *MockDispatcher) GetDispatchedMessages() []string
GetDispatchedMessages returns a slice of all dispatched messages
func (*MockDispatcher) WithLogLevel ¶
func (ld *MockDispatcher) WithLogLevel(level LogLevel) Dispatcher
WithLogLevel sets the log dispatcher level and returns the dispatcher
type MuxDispatcher ¶
type MuxDispatcher struct {
// contains filtered or unexported fields
}
MuxDispatcher holds is a concurrent-safe collection of loggers
func NewLogDispatcher ¶
func NewLogDispatcher(loggers ...Logger) *MuxDispatcher
NewLogDispatcher properly creates a new log dispatcher initializing the mutex and loggers slice
func (*MuxDispatcher) Add ¶
func (ld *MuxDispatcher) Add(loggers ...Logger)
Add adds aa logger to the dispatcher
func (*MuxDispatcher) Dispatch ¶
func (ld *MuxDispatcher) Dispatch(msg LogMessage) error
Dispatch iterates over dispatcher loggers and logs the given message for each one of them
func (*MuxDispatcher) WithLogLevel ¶
func (ld *MuxDispatcher) WithLogLevel(level LogLevel) Dispatcher
WithLogLevel sets the log dispatcher level and returns the dispatcher
type Request ¶
type Request struct {
Method string `json:"method,omitempty"`
}
Request is the structure of an http request
func NewRequest ¶
func NewRequest() Request
NewRequest creates a new Request and properly initializes all required fields
func (Request) WithMethod ¶
WithMethod sets the request method field and returns the request itself
type Response ¶
type Response struct { Body string `json:"method,omitempty"` StatusCode uint16 `json:"status_code,omitempty"` }
Response is the structure of an http response
func NewResponse ¶
func NewResponse() Response
NewResponse creates a new Response and properly initializes all required fields
func (Response) WithStatusCode ¶
WithStatusCode sets the response status code field and returns the request itself