Documentation
¶
Overview ¶
Package log provides a log interface
Index ¶
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Init(opts ...Option) error
- func Log(level Level, v ...interface{})
- func Logf(level Level, format string, v ...interface{})
- func NewContext(ctx context.Context, l Logger) context.Context
- func String() string
- func Trace(args ...interface{})
- func Tracef(template string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Level
- type Logger
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Level ¶
type Level int8
const ( // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel Level = iota - 2 // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // InfoLevel is the default logging priority. // General operational entries about what's going on inside the application. InfoLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. ErrorLevel // FatalLevel level. Logs and then calls `logger.Exit(1)`. highest level of severity. FatalLevel )
func GetLevel ¶ added in v2.1.1
GetLevel converts a level string into a logger Level value. returns an error if the input string does not match known values.
type Logger ¶
type Logger interface {
// Init initialises options
Init(options ...Option) error
// The Logger options
Options() Options
// Error set `error` field to be logged
Error(err error) Logger
// Fields set fields to always be logged
Fields(fields map[string]interface{}) Logger
// Log writes a log entry
Log(level Level, v ...interface{})
// Logf writes a formatted log entry
Logf(level Level, format string, v ...interface{})
// String returns the name of logger
String() string
}
Logger is a generic logging interface
type Option ¶
type Option func(*Options)
func WithFields ¶ added in v2.1.1
WithFields set default fields for the logger
func WithOutput ¶ added in v2.1.1
WithOutput set default output writer for the logger
type Options ¶
type Options struct {
// The logging level the logger should log at. default is `InfoLevel`
Level Level
// fields to always be logged
Fields map[string]interface{}
// It's common to set this to a file, or leave it default which is `os.Stderr`
Out io.Writer
// Alternative options
Context context.Context
}
Click to show internal directories.
Click to hide internal directories.