A simple prefixer logger that can wrap several backends. The formatters/handlers from this repository must be used in order to make prefix work.
type Logger interface {
WithPrefix(prefix string) Logger
WithPrefixf(format string, args ...interface{}) Logger
WithField(key string, value interface{}) Logger
WithError(error error) Logger
WithFields(fields map[string]interface{}) Logger
//
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
//
Print(args ...interface{})
Printf(format string, args ...interface{})
Println(args ...interface{})
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Fatalln(args ...interface{})
Panic(args ...interface{})
Panicf(format string, args ...interface{})
Panicln(args ...interface{})
}
- Logrus with
logger.WrapLogrus(l *logrus.Logger)
function - slog with
logger.WrapSlog(l *slog.Logger)
function- slog_gelf_handler.go can be used independently
- slog_text_handler.go (logrus format) can be used independently
type M map[string]interface{}
used as a shorthand for a map of interfaces used byWithFields
methodfunc WithLogger(ctx context.Context, l Logger) context.Context
to embeds the logger inside a contextfunc LogWith(ctx context.Context) Logger
to extract a logger from a context
MIT
All PRs are welcome.
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request