Documentation ¶
Index ¶
- Variables
- func Errorf(s string, args ...interface{})
- func Patch(options ...Option)
- type Format
- type Level
- type Logger
- func (l *Logger) Critical(s string)
- func (l *Logger) Criticalf(format string, args ...interface{})
- func (l *Logger) Debug(s string)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(s string)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Info(s string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) New(options ...Option) *Logger
- func (l *Logger) Patch(options ...Option)
- func (l *Logger) Trace(s string)
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warn(s string)
- func (l *Logger) Warnf(format string, args ...interface{})
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrLevelNotRecognised = errors.New("level is not recognised") ErrLevelIntegerOutOfRange = errors.New("level integer can only be between 0 and 5 included") )
Functions ¶
Types ¶
type Level ¶
type Level uint8
Level is the level of the logger.
const ( // Critical is the cirtical (crit) level. Critical Level = iota // Error is the error (eror) level. Error // Warn is the warn level. Warn // Info is the info level. Info // Debug is the debug (dbug) level. Debug // Trace is the trace (trce) level. Trace // DoNotChange indicates the level of the logger should be // left as is. DoNotChange Level = Level(^uint8(0)) )
func ParseLevel ¶
ParseLevel parses a string into a level, and returns an error if it fails. It accepts integers between 0 (critical) and 5 (trace) as well as strings such as 'trace' or 'dbug'.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the logger implementation structure. It is thread safe to use.
func New ¶
New creates a new logger. It can only be called once per writer. If you want to create more loggers with different settings for the same writer, child loggers can be created using the New(options) method, to ensure thread safety on the same writer.
func NewFromGlobal ¶
NewFromGlobal creates a child logger from the global logger.
func (*Logger) New ¶
New creates a new thread safe child logger. It can use a different writer, but it is expected to use the same writer since it is thread safe.
func (*Logger) Patch ¶
Patch patches the existing settings with any option given. This is thread safe and propagates to all child loggers. TODO-1946 remove patch progagation to child loggers.
type Option ¶
type Option func(s *settings)
Option is the type to specify settings modifier for the logger operation.
func AddContext ¶
AddContext adds the context for the logger as a key values pair. It adds them in order. If a key already exists, the value is added to the existing values.
func SetCallerFile ¶
SetCallerFile enables or disables logging the caller file. The default is disabled.
func SetCallerFunc ¶
SetCallerFunc enables or disables logging the caller function. The default is disabled.
func SetCallerLine ¶
SetCallerLine enables or disables logging the caller line number. The default is disabled.