Documentation ¶
Index ¶
Constants ¶
const ( GelfVersion = "1.1" GelfVersionKey = "version" GelfHostKey = "host" GelfShortKey = "short_message" GelfFullKey = "full_message" GelfTimestampKey = "timestamp" GelfLevelKey = "level" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldArray ¶
type FieldArray []logr.Field
func (FieldArray) MarshalJSONObject ¶
func (fa FieldArray) MarshalJSONObject(enc *gojay.Encoder)
MarshalJSONObject encodes Fields map to JSON.
type Gelf ¶
type Gelf struct { // Hostname allows a custom hostname, otherwise os.Hostname is used Hostname string `json:"hostname"` // EnableCaller enables output of the file and line number that emitted a log record. EnableCaller bool `json:"enable_caller"` // FieldSorter allows custom sorting for the context fields. FieldSorter func(fields []logr.Field) []logr.Field `json:"-"` }
Gelf formats log records as GELF rcords (https://docs.graylog.org/en/4.0/pages/gelf.html).
func (*Gelf) CheckValid ¶
func (*Gelf) IsStacktraceNeeded ¶
IsStacktraceNeeded returns true if a stacktrace is needed so we can output the `Caller` field.
type JSON ¶
type JSON struct { // DisableTimestamp disables output of timestamp field. DisableTimestamp bool `json:"disable_timestamp"` // DisableLevel disables output of level field. DisableLevel bool `json:"disable_level"` // DisableMsg disables output of msg field. DisableMsg bool `json:"disable_msg"` // DisableFields disables output of all fields. DisableFields bool `json:"disable_fields"` // DisableStacktrace disables output of stack trace. DisableStacktrace bool `json:"disable_stacktrace"` // EnableCaller enables output of the file and line number that emitted a log record. EnableCaller bool `json:"enable_caller"` // TimestampFormat is an optional format for timestamps. If empty // then DefTimestampFormat is used. TimestampFormat string `json:"timestamp_format"` // KeyTimestamp overrides the timestamp field key name. KeyTimestamp string `json:"key_timestamp"` // KeyLevel overrides the level field key name. KeyLevel string `json:"key_level"` // KeyMsg overrides the msg field key name. KeyMsg string `json:"key_msg"` // KeyGroupFields when not empty will group all context fields // under this key. KeyGroupFields string `json:"key_group_fields"` // KeyStacktrace overrides the stacktrace field key name. KeyStacktrace string `json:"key_stacktrace"` // KeyCaller overrides the caller field key name. KeyCaller string `json:"key_caller"` // FieldSorter allows custom sorting of the fields. If nil then // no sorting is done. FieldSorter func(fields []logr.Field) []logr.Field `json:"-"` // contains filtered or unexported fields }
JSON formats log records as JSON.
func (*JSON) CheckValid ¶
func (*JSON) IsStacktraceNeeded ¶
IsStacktraceNeeded returns true if a stacktrace is needed so we can output the `Caller` field.
type JSONLogRec ¶
type JSONLogRec struct { *logr.LogRec *JSON // contains filtered or unexported fields }
JSONLogRec decorates a LogRec adding JSON encoding.
func (JSONLogRec) IsNil ¶
func (rec JSONLogRec) IsNil() bool
IsNil returns true if the LogRec pointer is nil.
func (JSONLogRec) MarshalJSONObject ¶
func (jlr JSONLogRec) MarshalJSONObject(enc *gojay.Encoder)
MarshalJSONObject encodes the LogRec as JSON.
type Plain ¶
type Plain struct { // DisableTimestamp disables output of timestamp field. DisableTimestamp bool `json:"disable_timestamp"` // DisableLevel disables output of level field. DisableLevel bool `json:"disable_level"` // DisableMsg disables output of msg field. DisableMsg bool `json:"disable_msg"` // DisableFields disables output of all fields. DisableFields bool `json:"disable_fields"` // DisableStacktrace disables output of stack trace. DisableStacktrace bool `json:"disable_stacktrace"` // EnableCaller enables output of the file and line number that emitted a log record. EnableCaller bool `json:"enable_caller"` // Delim is an optional delimiter output between each log field. // Defaults to a single space. Delim string `json:"delim"` // MinLevelLen sets the minimum level name length. If the level name is less // than the minimum it will be padded with spaces. MinLevelLen int `json:"min_level_len"` // MinMessageLen sets the minimum msg length. If the msg text is less // than the minimum it will be padded with spaces. MinMessageLen int `json:"min_msg_len"` // TimestampFormat is an optional format for timestamps. If empty // then DefTimestampFormat is used. TimestampFormat string `json:"timestamp_format"` // LineEnd sets the end of line character(s). Defaults to '\n'. LineEnd string `json:"line_end"` // EnableColor sets whether output should include color. EnableColor bool `json:"enable_color"` }
Plain is the simplest formatter, outputting only text with no colors.
func (*Plain) CheckValid ¶
func (*Plain) Format ¶
func (p *Plain) Format(rec *logr.LogRec, level logr.Level, buf *bytes.Buffer) (*bytes.Buffer, error)
Format converts a log record to bytes.
func (*Plain) IsStacktraceNeeded ¶
IsStacktraceNeeded returns true if a stacktrace is needed so we can output the `Caller` field.