chore: fix warnings (#3989)

This commit is contained in:
Kevin Wan
2024-03-08 22:35:17 +08:00
committed by GitHub
parent 69bb746a1d
commit 159ecb7386
32 changed files with 64 additions and 61 deletions

View File

@@ -1,6 +1,6 @@
package logx
// A LessLogger is a logger that control to log once during the given duration.
// A LessLogger is a logger that controls to log once during the given duration.
type LessLogger struct {
*limitedExecutor
}

View File

@@ -86,7 +86,7 @@ func Debugv(v any) {
}
}
// Debugw writes msg along with fields into access log.
// Debugw writes msg along with fields into the access log.
func Debugw(msg string, fields ...LogField) {
if shallLog(DebugLevel) {
writeDebug(msg, fields...)
@@ -142,7 +142,7 @@ func Errorv(v any) {
}
}
// Errorw writes msg along with fields into error log.
// Errorw writes msg along with fields into the error log.
func Errorw(msg string, fields ...LogField) {
if shallLog(ErrorLevel) {
writeError(msg, fields...)
@@ -208,7 +208,7 @@ func Infov(v any) {
}
}
// Infow writes msg along with fields into access log.
// Infow writes msg along with fields into the access log.
func Infow(msg string, fields ...LogField) {
if shallLog(InfoLevel) {
writeInfo(msg, fields...)
@@ -254,11 +254,12 @@ func SetWriter(w Writer) {
}
}
// SetUp sets up the logx. If already set up, just return nil.
// we allow SetUp to be called multiple times, because for example
// SetUp sets up the logx.
// If already set up, return nil.
// We allow SetUp to be called multiple times, because, for example,
// we need to allow different service frameworks to initialize logx respectively.
func SetUp(c LogConf) (err error) {
// Just ignore the subsequent SetUp calls.
// Ignore the later SetUp calls.
// Because multiple services in one process might call SetUp respectively.
// Need to wait for the first caller to complete the execution.
setupOnce.Do(func() {
@@ -480,7 +481,7 @@ func writeDebug(val any, fields ...LogField) {
getWriter().Debug(val, addCaller(fields...)...)
}
// writeError writes v into error log.
// writeError writes v into the error log.
// Not checking shallLog here is for performance consideration.
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.
@@ -520,7 +521,7 @@ func writeStack(msg string) {
getWriter().Stack(fmt.Sprintf("%s\n%s", msg, string(debug.Stack())))
}
// writeStat writes v into stat log.
// writeStat writes v into the stat log.
// Not checking shallLog here is for performance consideration.
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
// The caller should check shallLog before calling this function.

View File

@@ -570,7 +570,7 @@ func TestErrorfWithWrappedError(t *testing.T) {
old := writer.Swap(w)
defer writer.Store(old)
Errorf("hello %w", errors.New(message))
Errorf("hello %s", errors.New(message))
assert.True(t, strings.Contains(w.String(), "hello there"))
}

View File

@@ -319,7 +319,7 @@ func (l *RotateLogger) maybeCompressFile(file string) {
}()
if _, err := os.Stat(file); err != nil {
// file not exists or other error, ignore compression
// file doesn't exist or another error, ignore compression
return
}