Documentation ¶
Overview ¶
Package log defines the Logger interface and a basic implementation.
Index ¶
Constants ¶
const ( FieldKeyError = "error" FieldKeyLevel = "level" FieldKeyMessage = "msg" FieldKeyTime = "time" )
Common field keys.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
type Field interface { Key() string Get() interface{} }
Field is the interface implemented by types that store structured data for logging.
func FromContext ¶
FromContext returns the fields stored in ctx.
type Formatter ¶ added in v0.2.0
Formatter is the interface implemented by types that can format a Log entry.
type JSONFormat ¶ added in v0.2.0
type JSONFormat struct{}
JSONFormat formats log entries as JSON.
func (JSONFormat) Format ¶ added in v0.2.0
func (JSONFormat) Format(e entry) ([]byte, error)
Format implements the Formatter interface.
type Level ¶
type Level int8
Level is the log severity level.
const ( LevelTrace Level = iota - 2 LevelDebug LevelInfo LevelWarning LevelError LevelFatal // Logger implementations may call os.Exit(1). LevelPanic // Logger implementations may panic. )
Common log severity levels.
func ParseLevel ¶ added in v0.1.3
ParseLevel parses s into a Level.
func (Level) Get ¶ added in v0.1.3
func (l Level) Get() interface{}
Get implements the Field and flag.Getter interfaces.
func (Level) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Level) UnmarshalText ¶ added in v0.1.3
UnmarshalText implements encoding.TextUnmarshaler.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a basic leveled, structured log.
type Msg ¶
type Msg string
Msg is a log message.
type TextFormat ¶ added in v0.2.0
type TextFormat struct{}
TextFormat formats log entries as plain text.
func (TextFormat) Format ¶ added in v0.2.0
func (TextFormat) Format(e entry) ([]byte, error)
Format implements the Formatter interface.