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
Put some space for non-assets requests in development mode #23443
Put some space for non-assets requests in development mode #23443
Conversation
Shouldn't one space be enough? Having two lines between requests feels airy to me 😄 Can we make it so that there's a line just above the first asset request? Basically add a newline after: https://gist.github.com/prathamesh-sonpatki/ca9dbc32bcbae9066562#file-gistfile1-txt-L31 |
Almost! These should just be one line, IMO: https://gist.github.com/prathamesh-sonpatki/c9075f78ac6f1f372c7c#file-gistfile1-txt-L16-L17 😁 |
# Put some space between for non-assets requests in development logs. | ||
if development? && request.path !~ /^\/assets/ | ||
logger.debug '' | ||
logger.debug '' |
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.
why? logger.debug ''
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.
# Put some space between for non-assets requests in development logs.
😁
230e400
to
45d76a7
Compare
@kaspth For that we will need to know previous request path and based on that make a decision whether to show the line or not. I guess it will be more complicated. |
@prathamesh-sonpatki do we? Isn't outputting a space after every non asset request enough to get the result? |
@kaspth That will work for non-asset request and asset request sequence but will not work for asset-request and non-asset request sequence. For eg.
|
I also tried this suggestion from DHH in #23428. With this approach we will get same result as in https://gist.github.com/prathamesh-sonpatki/ca9dbc32bcbae9066562. There will be no extra line before assets request as present here - https://gist.github.com/prathamesh-sonpatki/c9075f78ac6f1f372c7c |
@@ -79,6 +82,12 @@ def development? | |||
def logger | |||
Rails.logger | |||
end | |||
|
|||
def show_extra_line_in_development_for_non_assets_requests(path) | |||
if development? && path !~ /^\/assets/ |
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.
Does this work safely to handle public assets, assets from engines, vendored assets, etc?
btw, this won't work with http://guides.rubyonrails.org/asset_pipeline.html#changing-the-assets-path
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.
Nice catch! It works with vendored assets but won't work with changing assets path.
45d76a7
to
0932edc
Compare
I used DHH's original suggestion, it does not print a new line after all assets requests end but covers all other cases. |
@@ -26,6 +26,9 @@ def process_action(event) | |||
end | |||
message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{event.duration.round}ms" | |||
message << " (#{additions.join(" | ".freeze)})" unless additions.blank? | |||
message << " (#{additions.join(" | ".freeze)})" unless additions.blank? |
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.
Don't think we need this 😉
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.
Fixed 😄
0932edc
to
7ca7c0e
Compare
1 similar comment
…elopment Put some space for non-assets requests in development mode
@@ -26,6 +26,8 @@ def process_action(event) | |||
end | |||
message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{event.duration.round}ms" | |||
message << " (#{additions.join(" | ".freeze)})" unless additions.blank? | |||
message << "\n\n" if Rails.env.development? |
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.
This is coupling Action Pack with Railties we should check if Rails.env
is defined before calling 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.
@rafaelfranca fixed @ 4e4bcae
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.
Thanks!
r? @dhh
Here is the sample output on an app created from rails master with this change - https://gist.github.com/prathamesh-sonpatki/ca9dbc32bcbae9066562
EDIT: Updated gist with Kasper's suggestion of printing a line before starting assets request - https://gist.github.com/prathamesh-sonpatki/c9075f78ac6f1f372c7c