logger/log/say.go
2022-09-07 18:04:24 +08:00

86 lines
2.1 KiB
Go

package log
import (
"encoding/json"
"go.uber.org/zap"
)
// Debug uses fmt.Sprint to construct and log a message.
func Debug(args ...interface{}) {
defer zap.S().Sync()
zap.S().Debug(args...)
}
// Info uses fmt.Sprint to construct and log a message.
func Info(args ...interface{}) {
defer zap.S().Sync()
zap.S().Info(args...)
}
// Warn uses fmt.Sprint to construct and log a message.
func Warn(args ...interface{}) {
defer zap.S().Sync()
zap.S().Warn(args...)
}
// Error uses fmt.Sprint to construct and log a message.
func Error(args ...interface{}) {
defer zap.S().Sync()
zap.S().Error(args...)
}
// Panic uses fmt.Sprint to construct and log a message, then panics.
func Panic(args ...interface{}) {
defer zap.S().Sync()
zap.S().Panic(args...)
}
// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func Fatal(args ...interface{}) {
defer zap.S().Sync()
zap.S().Fatal(args...)
}
// Debugf uses fmt.Sprintf to log a templated message.
func Debugf(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Debugf(template, args...)
}
// Infof uses fmt.Sprintf to log a templated message.
func Infof(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Infof(template, args...)
}
// Warnf uses fmt.Sprintf to log a templated message.
func Warnf(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Warnf(template, args...)
}
// Errorf uses fmt.Sprintf to log a templated message.
func Errorf(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Errorf(template, args...)
}
// Panicf uses fmt.Sprintf to log a templated message, then panics.
func Panicf(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Panicf(template, args...)
}
// Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
func Fatalf(template string, args ...interface{}) {
defer zap.S().Sync()
zap.S().Fatalf(template, args...)
}
// Pretty provides pretty trace level logging
func Pretty(v ...interface{}) {
b, _ := json.MarshalIndent(v, "", " ")
defer zap.S().Sync()
zap.S().Info(string(b))
}