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" // ERROR is a log level. ERROR = "error" // WARN is a log level. WARN = "warning" )
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") // ErrTimestamp is returned when the timestamp is not valid. ErrTimestamp = errors.New("invalid timestamp") // ErrEmptyObject is retuned when the payload is an empty object. ErrEmptyObject = errors.New("empty object") // ErrCorruptedJSON is returned the payload is corrupted. ErrCorruptedJSON = errors.New("corrupted json") )
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
type TextFormatter ¶ added in v0.0.2
type TextFormatter struct {
logrus.TextFormatter
}
TextFormatter is used for rendering a custom format. We need to put the time at the very beginning of the line.
Click to show internal directories.
Click to hide internal directories.