-
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
update log level setting, close #44 #45
update log level setting, close #44 #45
Conversation
1 similar comment
end | ||
|
||
def call(request_env, next_fn, level) do | ||
def call(request_env, next_fn, options) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move message formatting logic into a separate method, so we can implment the call function more concisely.
start_time = :erlang.system_time :micro_seconds
next_fn.(request_env) |> log_request(start_time, options)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think call
function is concisely enough, if you still think there're too many logic into it, we can make another pr to fix it.
that's how plug do time format https://github.com/elixir-lang/plug/blob/master/lib/plug/logger.ex#L45-L46
lib/maxwell/middleware/logger.ex
Outdated
end | ||
|
||
def call(request_env, next_fn, level) do | ||
def call(request_env, next_fn, options) do | ||
start_time = :os.timestamp() | ||
new_result = next_fn.(request_env) | ||
method = request_env.method |> to_string |> String.upcase | ||
case new_result do | ||
{:error, reason, _conn} -> | ||
error_reason = to_string(:io_lib.format("~p", [reason])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wonder, why not to use inspect
here.
lib/maxwell/middleware/logger.ex
Outdated
end | ||
|
||
unless is_nil(color) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know is_nil(color)
is equal to is_nil(level)
, but the later one would be more straitforward.
3 similar comments
1 similar comment
Thanks for the PR!! 👏 🎊 |
No description provided.