rs / rest-layer

REST Layer, Go (golang) REST API framework
http://rest-layer.io
MIT License
1.26k stars 114 forks source link

Newest `zerolog` versions cause a panic #261

Closed Dragomir-Ivanov closed 5 years ago

Dragomir-Ivanov commented 5 years ago

With the latest zerolog versions TraceLevel Level = -1 is introduced, causing DebugLevel to go from 0 to 1. This leads to panicking examples because of this fragment of code:

    resource.Logger = func(ctx context.Context, level resource.LogLevel, msg string, fields map[string]interface{}) {
        zerolog.Ctx(ctx).WithLevel(zerolog.Level(level)).Fields(fields).Msg(msg)
    }

With LogLevelDebug being 0 in rest-layer the automatic remap with zerolog.Level(level) panics because there is no more 0 level in zerolog.

What is the best course of action? Introducing LogLevelTrace in rest-layer mimicking zerolog and probably causing breaking change, because of tying rest-layer with newest versions of zerolog or manual re-translation in the above callback?

rs commented 5 years ago

LogLevelDebug is still 0, the trace is now -1. What does the trace say?

rs commented 5 years ago

Actually you're right, we use -1 so we don't renumber levels in https://github.com/rs/zerolog/pull/158, but the way it has been added shifted everything. I will push a quick fix, sorry about that.

rs commented 5 years ago

https://github.com/rs/zerolog/commit/54e95fe699887cea98e06d2928c5420a12c55c0f

Dragomir-Ivanov commented 5 years ago

Cool, thanks @rs ! Closing.