Documentation ¶
Index ¶
- func ContextWithLogger(ctx context.Context, logger *Logger) context.Context
- func JSONStreamer(r io.Reader, log *Logger, defaultLevel Level) error
- func LevelStrings() []string
- type Config
- type Entry
- type Interface
- type Level
- type Logger
- func (l Logger) AddSink(sink Sink) *Logger
- func (l Logger) Attrs(attributes map[string]string) *Logger
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Errorf(err error, format string, args ...interface{})
- func (l Logger) GetLevel() Level
- func (l *Logger) Infof(format string, args ...interface{})
- func (l Logger) Level(level Level) *Logger
- func (l *Logger) Log(entry Entry)
- func (l *Logger) Logf(level Level, format string, args ...interface{})
- func (l Logger) Scope(scope string) *Logger
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WriterAt(level Level) *io.PipeWriter
- type Sink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithLogger ¶
ContextWithLogger returns a new context with the given logger attached. Use FromContext to retrieve it.
func JSONStreamer ¶
JSONStreamer reads a stream of JSON log entries from r and logs them to log.
If a line of JSON is invalid an entry is created at the defaultLevel.
func LevelStrings ¶
func LevelStrings() []string
LevelStrings returns a slice of all String values of the enum
Types ¶
type Config ¶
type Config struct { Level Level `help:"Log level." default:"info" env:"LOG_LEVEL"` JSON bool `help:"Log in JSON format." env:"LOG_JSON"` }
Config for the logger.
type Interface ¶
type Interface interface { Log(entry Entry) Logf(level Level, format string, args ...interface{}) Tracef(format string, args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) // Errorf conditionally logs an error. If err is nil, nothing is logged. Errorf(err error, format string, args ...interface{}) }
type Level ¶
type Level int
Level is the log level.
const ( // Default is a special value that means the log level will use a default. Default Level = 0 Trace Level = 1 Debug Level = 5 Info Level = 9 Warn Level = 13 Error Level = 17 )
Log levels.
func LevelString ¶
LevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ParseLevel ¶
ParseLevel parses a log level from text.
func (Level) IsALevel ¶
IsALevel returns "true" if the value is listed in the enum definition. "false" otherwise
func (Level) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Level
func (*Level) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Level
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the concrete logger.
func FromContext ¶
FromContext retrieves the current logger from the context or panics