Documentation
¶
Overview ¶
Package handler contains all handlers for serving POST requests. The payload should have at least one key: message. And it contains the log entry for writing. If a "type" for the entry is not provided, it falls back to "info". If the "timestamp" is not provided, it uses the current time it receives the payload.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoWriter is returned when no write is provided. ErrNoWriter = errors.New("no writers specified") // ErrNoLogger is returned when no logger specified. ErrNoLogger = errors.New("no logger specified") // ErrNilLogger is returned when nil logger specified. ErrNilLogger = errors.New("nil logger specified") // ErrDuplicateWriter is returned on duplicated writers. ErrDuplicateWriter = errors.New("duplicated writer") // ErrWritingEntry is for when there is a problem with writing the entry. ErrWritingEntry = errors.New("writing the entry") // ErrEmptyObject is retuned when the payload is an empty object. ErrEmptyObject = errors.New("empty object") // ErrGettingReader is returned when the reader factory cannot return an // appropriate reader for the entry. ErrGettingReader = errors.New("getting reader") // ErrGettingMap is returned when the payload does not contain a map. ErrGettingMap = errors.New("getting map") // ErrCorruptedJSON is returned the payload is corrupted. ErrCorruptedJSON = errors.New("corrupted json") // ErrNoOptions is returned when no option is provided. ErrNoOptions = errors.New("no option provided") )
Functions ¶
func WithLogger ¶ added in v0.0.3
func WithLogger(logger internal.FieldLogger) func(*Service) error
WithLogger will return an error if the logger is nil
Types ¶
type Service ¶
type Service struct {
Writers []io.Writer
Logger internal.FieldLogger
}
Service listens to the incoming http requests and decides how to route the payload to be written.
func (*Service) RecieveHandler ¶
func (l *Service) RecieveHandler(w http.ResponseWriter, r *http.Request)
RecieveHandler handles the logs coming from the endpoint. It handles all writes in their own goroutine in order to avoid write loss.
Click to show internal directories.
Click to hide internal directories.