Documentation
¶
Overview ¶
Package reader contains a series of readers that can understand how an entry can be written to a destination. Plain will produce a one line entry to be written on the logs, like how nginx logs look like.
Index ¶
Constants ¶
View Source
const (
// INFO is a log level.
INFO = "INFO"
)
Variables ¶
View Source
var ( // ErrNilTimestamp is returned when timestamp is and empty time.Time ErrNilTimestamp = errors.New("nil timestamp") // ErrEmptyMessage is returned when the message body is an empty string. ErrEmptyMessage = errors.New("empty message") // ErrDecodeJSON is returned when the payload is not JSON unmarshallable. ErrDecodeJSON = errors.New("decoding json object") // ErrTimestamp is returned when the timestamp is not valid. ErrTimestamp = errors.New("invalid timestamp") )
View Source
var TimestampFormat = time.RFC3339
TimestampFormat is the default formatting defined for logs.
Functions ¶
Types ¶
type Plain ¶
type Plain struct {
Kind string
Message string
Timestamp time.Time
Logger internal.FieldLogger
// contains filtered or unexported fields
}
Plain implements the io.Reader interface and can read a json object and output a one line error message. For example:
{
"type": "error",
"timestamp": "2017-10-09 10:45:00",
"message": "something happened",
}
Will become:
[2017-10-09 10:45:00] [ERROR] something happened
Click to show internal directories.
Click to hide internal directories.