Documentation ¶
Index ¶
- Variables
- type ChildConstructor
- type Level
- type LeveledLogger
- type Logger
- 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) Warn(s string)
- func (l *Logger) Warnf(format string, args ...interface{})
- type LoggerInterface
- type LoggerPatcher
- type Option
- func AddWriters(writers ...io.Writer) Option
- func SetCallerFile(enabled bool) Option
- func SetCallerFunc(enabled bool) Option
- func SetCallerLine(enabled bool) Option
- func SetComponent(component string) Option
- func SetLevel(level Level) Option
- func SetTimeFormat(timeFormat string) Option
- func SetWriters(writers ...io.Writer) Option
Constants ¶
This section is empty.
Variables ¶
var (
ErrLevelNotRecognized = errors.New("level is not recognized")
)
Functions ¶
This section is empty.
Types ¶
type ChildConstructor ¶
ChildConstructor is the interface to create child loggers.
type Level ¶
type Level uint8
Level is the level of the logger.
func ParseLevel ¶
ParseLevel parses a string into a level, and returns an error if it fails.
func (Level) ColoredString ¶
ColoredString returns the corresponding colored string for the level.
type LeveledLogger ¶
type LeveledLogger interface { Debug(s string) Info(s string) Warn(s string) Error(s string) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) }
LeveledLogger is the interface to log at different levels.
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, with thread safety each of its writers and other loggers. You can pass options to configure the logger.
func (*Logger) New ¶
New creates a child logger inheriting from the settings of the current logger. Options can be passed to modify the settings of the new child logger to be created.
type LoggerInterface ¶
type LoggerInterface interface { LeveledLogger LoggerPatcher ChildConstructor }
type LoggerPatcher ¶
type LoggerPatcher interface {
Patch(options ...Option)
}
LoggerPatcher is the interface to update the current logger.
type Option ¶
type Option func(s *settings)
Option is the type to specify settings modifier for the logger operation.
func AddWriters ¶
AddWriters adds the writers given to the existing writers for the logger. The writers defaults to a single writer of os.Stdout.
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.
func SetComponent ¶
SetComponent sets the component for the logger which will be logged on every log operation. Set it to the empty string so no component is logged. The default is the empty string component.
func SetLevel ¶
SetLevel sets the level for the logger. The level defaults to the lowest level, error.
func SetTimeFormat ¶
SetTimeFormat set the time format for the logger. You can set it to an empty string in order to not log the time. The time format defaults to time.RFC3339.
func SetWriters ¶
SetWriters sets the writers for the logger. The writers defaults to a single writer of os.Stdout.