-
Notifications
You must be signed in to change notification settings - Fork 32
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
adding an option to format log message to be one line #16
Conversation
This looks pretty sweet! I'm all for it! How about changing the option name though? What do you think about |
Sure. I like |
b00d3cb
to
6546c93
Compare
@ridiculous I refactored how the logger is being called here. The idea was to isolate the logic that the :condensed option needs to one place. Let me know if that works for you. My initial concern about it is the speed of doing the compact, delete_if, strip! and join on every log statement. I could also do logger.info(
log_statements.inject([]) do |condensed_statement, log_statement|
next condensed_statement if log_statement.nil? || log_statement.empty?
condensed_statement << log_statement.strip
end.join(" - ")
) so it only iterates 2 times instead of 4 times |
@@ -64,8 +69,12 @@ def call!(env) | |||
end | |||
|
|||
def after(status) | |||
logger.info "Completed #{status} in #{((Time.now - start_time) * 1000).round(2)}ms" | |||
logger.info '' | |||
log_info( |
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'd prefer to keep this as 2 statements, instead of creating a new array object for it
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.
Sry, I misread this, didn't see it was a new method log_info
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 like the direction this is going. If we really want to make this fast, efficient and organized, we may want to add this as an optional plugin or file that's loaded at boot time, instead of checking at runtime if it's "condensed." What do you think about that? I'm thinking we could mount a different class?
mount Grape::Middleware::CondensedLogger
Any thoughts on my proposal, @mmclead? |
The proposal sounds great. I just haven't had the time to put in the work. Its on my radar though, and hopefully will get to it soon. (product launch at work is in the next couple weeks) |
I'd love to have this option. :) |
@mmclead @ridiculous |
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.
Sorry for dropping the ball here. But this looks good! Let's do it! PS I should just give you commit access
released in v1.11.0 |
I'm using this to make searching logs easier. When filtering on a keyword the current multi-line log format makes it more difficult to get to all the information that is being logged.
This will add a configuration to the logger to format all the same information into one log line before processing the request and after processing the request.