Skip to content
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

Merged

Conversation

falood
Copy link
Collaborator

@falood falood commented Feb 13, 2017

No description provided.

@coveralls
Copy link

coveralls commented Feb 13, 2017

Coverage Status

Coverage decreased (-1.0%) to 99.002% when pulling 81dd679 on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.0%) to 99.002% when pulling 81dd679 on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

@coveralls
Copy link

coveralls commented Feb 13, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 32e1251 on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

end

def call(request_env, next_fn, level) do
def call(request_env, next_fn, options) do
Copy link
Collaborator

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)

Copy link
Collaborator Author

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

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]))
Copy link
Collaborator

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.

end

unless is_nil(color) do
Copy link
Collaborator

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 557abea on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 557abea on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 557abea on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 557abea on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

@coveralls
Copy link

coveralls commented Feb 13, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling ff0aaa7 on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ff0aaa7 on falood:multiple_level_for_logger_middleware into 220379e on zhongwencool:master.

@zhongwencool
Copy link
Owner

Thanks for the PR!! 👏 🎊
Tomorrow, I will published 2.2.0 with this version :)

@zhongwencool zhongwencool merged commit d7cc317 into zhongwencool:master Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants