You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/log/helper.go

83 lines
2.0 KiB

4 years ago
package log
import (
"fmt"
)
// Helper is a logger helper.
type Helper struct {
logger Logger
4 years ago
}
// NewHelper new a logger helper.
func NewHelper(logger Logger) *Helper {
4 years ago
return &Helper{
logger: logger,
4 years ago
}
}
// Log .
func (h *Helper) Log(level Level, keyvals ...interface{}) {
h.logger.Log(level, keyvals...)
}
4 years ago
// Debug logs a message at debug level.
func (h *Helper) Debug(a ...interface{}) {
h.logger.Log(LevelDebug, "msg", fmt.Sprint(a...))
4 years ago
}
// Debugf logs a message at debug level.
func (h *Helper) Debugf(format string, a ...interface{}) {
h.logger.Log(LevelDebug, "msg", fmt.Sprintf(format, a...))
4 years ago
}
// Debugw logs a message at debug level.
func (h *Helper) Debugw(keyvals ...interface{}) {
h.logger.Log(LevelDebug, keyvals...)
4 years ago
}
// Info logs a message at info level.
func (h *Helper) Info(a ...interface{}) {
h.logger.Log(LevelInfo, "msg", fmt.Sprint(a...))
4 years ago
}
// Infof logs a message at info level.
func (h *Helper) Infof(format string, a ...interface{}) {
h.logger.Log(LevelInfo, "msg", fmt.Sprintf(format, a...))
4 years ago
}
// Infow logs a message at info level.
func (h *Helper) Infow(keyvals ...interface{}) {
h.logger.Log(LevelInfo, keyvals...)
4 years ago
}
// Warn logs a message at warn level.
func (h *Helper) Warn(a ...interface{}) {
h.logger.Log(LevelWarn, "msg", fmt.Sprint(a...))
4 years ago
}
// Warnf logs a message at warnf level.
func (h *Helper) Warnf(format string, a ...interface{}) {
h.logger.Log(LevelWarn, "msg", fmt.Sprintf(format, a...))
4 years ago
}
// Warnw logs a message at warnf level.
func (h *Helper) Warnw(keyvals ...interface{}) {
h.logger.Log(LevelWarn, keyvals...)
4 years ago
}
// Error logs a message at error level.
func (h *Helper) Error(a ...interface{}) {
h.logger.Log(LevelError, "msg", fmt.Sprint(a...))
4 years ago
}
// Errorf logs a message at error level.
func (h *Helper) Errorf(format string, a ...interface{}) {
h.logger.Log(LevelError, "msg", fmt.Sprintf(format, a...))
4 years ago
}
// Errorw logs a message at error level.
func (h *Helper) Errorw(keyvals ...interface{}) {
h.logger.Log(LevelError, keyvals...)
4 years ago
}