diff --git a/README.md b/README.md index 8bc3f78..d571ba3 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ import ( func main() { // 1. Basic case - log.Info() // "missing to dispatch with Msg or Send function. nothing will be logged" + log.Info() // "must be dispatched by Msg or Send method" // 2. Nested case - log.Info(). // "missing to dispatch with Msg or Send function. nothing will be logged" + log.Info(). // "must be dispatched by Msg or Send method" Str("foo", "bar"). Dict("dict", zerolog.Dict(). Str("bar", "baz"). @@ -37,9 +37,9 @@ func main() { ) // 3. Reassignment case - logger := log.Info() // "missing to dispatch with Msg or Send function. nothing will be logged" + logger := log.Info() // "must be dispatched by Msg or Send method" if err != nil { - logger = log.Error() // "missing to dispatch with Msg or Send function. nothing will be logged" + logger = log.Error() // "must be dispatched by Msg or Send method" } logger.Str("foo", "bar") } diff --git a/testdata/src/a/a.go b/testdata/src/a/a.go index 69d64c5..ce08c71 100644 --- a/testdata/src/a/a.go +++ b/testdata/src/a/a.go @@ -6,21 +6,21 @@ import ( ) func bad() { - log.Error() // want "missing to dispatch with Msg or Send function. nothing will be logged" - log.Info() // want "missing to dispatch with Msg or Send function. nothing will be logged" - log.Fatal() // want "missing to dispatch with Msg or Send function. nothing will be logged" - log.Debug() // want "missing to dispatch with Msg or Send function. nothing will be logged" - log.Warn() // want "missing to dispatch with Msg or Send function. nothing will be logged" + log.Error() // want "must be dispatched by Msg or Send method" + log.Info() // want "must be dispatched by Msg or Send method" + log.Fatal() // want "must be dispatched by Msg or Send method" + log.Debug() // want "must be dispatched by Msg or Send method" + log.Warn() // want "must be dispatched by Msg or Send method" var err error - log.Error().Err(err) // want "missing to dispatch with Msg or Send function. nothing will be logged" - log.Error().Err(err).Str("foo", "bar").Int("foo", 1) // want "missing to dispatch with Msg or Send function. nothing will be logged" + log.Error().Err(err) // want "must be dispatched by Msg or Send method" + log.Error().Err(err).Str("foo", "bar").Int("foo", 1) // want "must be dispatched by Msg or Send method" - logger := log.Error() // want "missing to dispatch with Msg or Send function. nothing will be logged" + logger := log.Error() // want "must be dispatched by Msg or Send method" logger.Err(err).Str("foo", "bar").Int("foo", 1) // include zerolog.Dict() - log.Info(). // want "missing to dispatch with Msg or Send function. nothing will be logged" + log.Info(). // want "must be dispatched by Msg or Send method" Str("foo", "bar"). Dict("dict", zerolog.Dict(). Str("bar", "baz"). @@ -28,9 +28,9 @@ func bad() { ) // conditional - logger2 := log.Info() // want "missing to dispatch with Msg or Send function. nothing will be logged" + logger2 := log.Info() // want "must be dispatched by Msg or Send method" if err != nil { - logger2 = log.Error() // want "missing to dispatch with Msg or Send function. nothing will be logged" + logger2 = log.Error() // want "must be dispatched by Msg or Send method" } logger2.Str("foo", "bar") } diff --git a/zerologlint.go b/zerologlint.go index 25017e4..ce9f584 100644 --- a/zerologlint.go +++ b/zerologlint.go @@ -75,7 +75,7 @@ func run(pass *analysis.Pass) (interface{}, error) { // At the end, if the set is clear -> ok. // Otherwise, there must be a left zerolog.Event var that weren't dispached. So report it. for k := range set { - pass.Reportf(k.Pos(), "missing to dispatch with Msg or Send function. nothing will be logged") + pass.Reportf(k.Pos(), "must be dispatched by Msg or Send method") } return nil, nil }