-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log middleware has problem receiving log level setting #44
Comments
Now: But: middleware Maxwell.Middleware.Logger, [code: 200] And change default behavior to not logged 200 code. |
@zhongwencool Yes, but I think a better solution would be providing a mechanism to let the user define which middleware Maxwell.Middleware.Logger, [log_level: :info] To log 2xx with info, others with error middleware Maxwell.Middleware.Logger, log_level: :info, codes: 200..299
middleware Maxwell.Middleware.Logger, log_level: :error, codes: [0..199, 300..999] But this method is too verbose for defining an exclusive case. Another idea is to use middleware Maxwell.Middleware.Logger, log_level: :error, codes: %{200..299 => :info, 300..399 => :warn} @zhongwencool any other ideas? |
I like the second idea~ middleware Maxwell.Middleware.Logger, log_level: [200..299 => :info,
300..399 => :warn, :default => :error] |
I have some suggestion about the DSL.
|
I got to say I kind of like @falood 's idea. Besides the keyword list accepting a callback could be even better. |
@zhongwencool I don't think putting default value together with special values is a good idea. middleware Maxwell.Middleware.Logger
# are equivalent to
middleware Maxwell.Middleware.Logger default: :error, log_level: %{200..299: :info, 300..399: :warn} @falood I agree with your suggestion on using the level as key. The concern here is the level of the log, so using it as the key would be more concise. middleware Maxwell.Middleware.Logger, default_level: :error, log_level: [
info: [1..100, 200..299],
warn: 300..399
]
# or with using :error as default level
middleware Maxwell.Middleware.Logger, log_level: [
info: [1..100, 200..299],
warn: 300..399
] |
@jackalcooper Using an inline function as an argument of the macro is not easy and will make this middleware be too complicate. If you have more complicated filtering conditions, writing a customized middleware would be a better solution. |
so, the
if
|
When I set it to
:error
When I set it to
:info
But there are all requests with 200 HTTP status code.
This is the log setting in my client:
The text was updated successfully, but these errors were encountered: