Documentation ¶
Index ¶
- type Event
- func (e *Event) Bool(key string, value bool) *Event
- func (e *Event) Bytes(key string, value []byte) *Event
- func (e *Event) CallStack() *Event
- func (e *Event) Caller() *Event
- func (e *Event) Err(err error) *Event
- func (e *Event) Float32(key string, f float32) *Event
- func (e *Event) Float64(key string, f float64) *Event
- func (e *Event) Int(key string, value int) *Event
- func (e *Event) Int16(key string, value int16) *Event
- func (e *Event) Int32(key string, value int32) *Event
- func (e *Event) Int64(key string, value int64) *Event
- func (e *Event) Int8(key string, value int8) *Event
- func (e *Event) Line() *Event
- func (e *Event) Msg(msg string)
- func (e *Event) Msgf(fmtstr string, vals ...interface{})
- func (e *Event) Str(key string, value string) *Event
- func (e *Event) Time(key string, value time.Time) *Event
- func (e *Event) Uint16(key string, value uint16) *Event
- func (e *Event) Uint32(key string, value uint32) *Event
- func (e *Event) Uint64(key string, value uint64) *Event
- func (e *Event) Uint8(key string, value uint8) *Event
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event represents the text collected for output to a given log Writer.
func (*Event) Bytes ¶
Bytes adds a key (variable name) and slice of bytes to the logging event in hex.
func (*Event) CallStack ¶ added in v1.1.0
CallStack() writes a call stack as @file_0..@file_n and @line_0..@line_n. The number of levels written is limited by the value of Logger.MaxCallLevels.
func (*Event) Caller ¶
Caller writes the line number and file of the source code that the current function was called from, as the @line_1 and @file_1 keys, as well as the current line and file as @line_0 and @file_0.
func (*Event) Line ¶
Line writes the current line number and file of the source code as the @line_0 and @file_0 keys.
func (*Event) Msg ¶
Msg writes the accumulated log entry to the log, along with the message provided.
func (*Event) Msgf ¶
Msgf writes a message formatted as per fmt.Sprintf. It's likely to be slower than any other log event method.
type Logger ¶
type Logger struct { ErrorWriter io.Writer // where to send Error() events InfoWriter io.Writer // where to send Info() events DebugWriter io.Writer // where to send Debug() events Timestamp string // format string for timestamps UTC bool // whether to write timestamps in UTC MaxCallLevels int // how many call levels CallStack() should write IncludeSystemFiles bool // whether to include system source files in the call stack ErrorTag []byte WarnTag []byte InfoTag []byte DebugTag []byte KeyStart []byte KeyEnd []byte Closer func() }
Logger represents an object you can create log events from.
func NewCloudLogger ¶ added in v1.0.3
func NewCloudLogger() *Logger
NewCloudLogger creates a new logger with output to stdout and stderr, no ANSI codes or timestamps. Suitable for Cloud Foundry, OpenShift, etc.
func NewConsoleLogger ¶
func NewConsoleLogger() *Logger
NewConsoleLogger creates a new logger with output to stdout and stderr, ANSI colored logging level tags, and timestamps to 1 second precision.
func NewFileLogger ¶
NewFileLogger creates a new logger with output to the error and info log filenames provided, no ANSI codes, and timestamps to 1 second precision.
func NewLogger ¶ added in v1.0.3
func NewLogger() *Logger
NewLogger attempts to determine whether stdout is connected to the console. If so, it returns a ConsoleLogger; if not, it looks for the PORT environment variable to determine whether to return a CloudLogger. If that isn't found, it returns a PipeLogger.
func NewPipeLogger ¶ added in v1.0.3
func NewPipeLogger() *Logger
NewPipeLogger creates a new logger with output to stdout and stderr, no ANSI codes, and timestamps to 1 second precision.
func (*Logger) Error ¶
Error returns an error level logging event you can add values and messages to