Documentation
¶
Overview ¶
Package log implements structured logging helpers.
Index ¶
Constants ¶
const ( // DBG represents debug data. DBG Level = 30 // INF represents machine-actionable data. INF = 34 // WRN represents human-observable data. WRN = 33 // ERR represents human-actionable data. ERR = 31 )
Level constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Level Level `json:"level"`
Message string `json:"message"`
Data M `json:"data,omitempty"`
Time time.Time `json:"time"`
}
Entry represents a log entry.
type Level ¶
type Level int
Level represents a log level.
func (Level) MarshalJSON ¶
MarshalJSON impelements the json.Marshaler interface.
func (*Level) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a logger.
func NewDiscardLogger ¶
func NewDiscardLogger() *Logger
NewDiscardLogger returns a *Logger that discards log entries.
func NewLogger ¶
NewLogger returns a *Logger that writes JSON encoded logs.
This logger is recommended for production. Entries with log level INF are discarded as they are intended to be purely informational and machine-actionable events. Entries with log level DBG will be logged if debug is true.
func NewMinimalShellLogger ¶
NewMinimalShellLogger returns a *Logger that writes text formatted logs with decorative shell colors but without timestamps and text levels.
func NewShellLogger ¶
NewShellLogger returns a *Logger that writes POSIX shell formatted logs.
func NewTextLogger ¶
NewTextLogger returns a *Logger that writes text formatted logs.
