1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/logger/helper.go
Vasiliy Tolstov 6b8930a960
add new helper method to logger (#1273)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-29 00:39:41 +00:00

66 lines
1.5 KiB
Go

package logger
type Helper struct {
Logger
}
func NewHelper(log Logger) *Helper {
return &Helper{log}
}
func (h *Helper) Info(args ...interface{}) {
h.Logger.Log(InfoLevel, args...)
}
func (h *Helper) Infof(template string, args ...interface{}) {
h.Logger.Logf(InfoLevel, template, args...)
}
func (h *Helper) Trace(args ...interface{}) {
h.Logger.Log(TraceLevel, args...)
}
func (h *Helper) Tracef(template string, args ...interface{}) {
h.Logger.Logf(TraceLevel, template, args...)
}
func (h *Helper) Debug(args ...interface{}) {
h.Logger.Log(DebugLevel, args...)
}
func (h *Helper) Debugf(template string, args ...interface{}) {
h.Logger.Logf(DebugLevel, template, args...)
}
func (h *Helper) Warn(args ...interface{}) {
h.Logger.Log(WarnLevel, args...)
}
func (h *Helper) Warnf(template string, args ...interface{}) {
h.Logger.Logf(WarnLevel, template, args...)
}
func (h *Helper) Error(args ...interface{}) {
h.Logger.Log(ErrorLevel, args...)
}
func (h *Helper) Errorf(template string, args ...interface{}) {
h.Logger.Logf(ErrorLevel, template, args...)
}
func (h *Helper) Fatal(args ...interface{}) {
h.Logger.Log(ErrorLevel, args...)
}
func (h *Helper) Fatalf(template string, args ...interface{}) {
h.Logger.Logf(ErrorLevel, template, args...)
}
func (h *Helper) WithError(err error) *Helper {
return &Helper{h.Logger.Fields(map[string]interface{}{"error": err})}
}
func (h *Helper) WithFields(fields map[string]interface{}) *Helper {
return &Helper{h.Logger.Fields(fields)}
}