add logx.DisableStat() to disable stat logs (#893)

* add logx.DisableStat() to disable stat logs

* refactor logx code
This commit is contained in:
Kevin Wan
2021-08-10 16:55:38 +08:00
committed by GitHub
parent af1730079e
commit 872e75e10d
4 changed files with 46 additions and 25 deletions

View File

@@ -18,37 +18,37 @@ type traceLogger struct {
}
func (l *traceLogger) Error(v ...interface{}) {
if shouldLog(ErrorLevel) {
if shallLog(ErrorLevel) {
l.write(errorLog, levelError, formatWithCaller(fmt.Sprint(v...), durationCallerDepth))
}
}
func (l *traceLogger) Errorf(format string, v ...interface{}) {
if shouldLog(ErrorLevel) {
if shallLog(ErrorLevel) {
l.write(errorLog, levelError, formatWithCaller(fmt.Sprintf(format, v...), durationCallerDepth))
}
}
func (l *traceLogger) Info(v ...interface{}) {
if shouldLog(InfoLevel) {
if shallLog(InfoLevel) {
l.write(infoLog, levelInfo, fmt.Sprint(v...))
}
}
func (l *traceLogger) Infof(format string, v ...interface{}) {
if shouldLog(InfoLevel) {
if shallLog(InfoLevel) {
l.write(infoLog, levelInfo, fmt.Sprintf(format, v...))
}
}
func (l *traceLogger) Slow(v ...interface{}) {
if shouldLog(ErrorLevel) {
if shallLog(ErrorLevel) {
l.write(slowLog, levelSlow, fmt.Sprint(v...))
}
}
func (l *traceLogger) Slowf(format string, v ...interface{}) {
if shouldLog(ErrorLevel) {
if shallLog(ErrorLevel) {
l.write(slowLog, levelSlow, fmt.Sprintf(format, v...))
}
}