-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Allow yield
to logger methods & bail early on no-op messages
#6315
Conversation
Standard loggers in Ruby mostly `yield` their messages (this is the default behavior of Ruby's own logger.) Or if there is a block then the message is the topic, a colon is automatically added, and the message is shipped with the topic. Jekyll should conform to this behavior so that it's logger can be passed to libraries that expect this standard behavior. ```ruby [1] pry(main)> Jekyll.logger.info("Just so you know") # => Just so you know [2] pry(main)> Jekyll.logger.info("Just so you know", "this is a message") # => Just so you know this is a message [3] pry(main)> Jekyll.logger.info("Just so you know") { "this is a message" } # => Just so you know: this is a message ``` Signed-off-by: Parker Moore <[email protected]>
f2d0a06
to
9737908
Compare
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 can only admire the work here, this seems pretty solid. 👏
Maybe @envygeeks wants to do a proper benchmark to see how this affect its build performance? With Jekyll's Before: real 2m24.422s
user 1m56.664s
sys 0m11.537s After:
|
Whoa, who knew logging could be so expensive! I just remembered that we can push this even further by setting the log level to On my MBP:
|
@jekyllbot: merge +minor |
This subsumes #6306 and fixes the bugs with that PR.
It also bails early for
debug
,info
,warn
, anderror
if the logger's log level is higher than the message's log level. In this case the logging writer will skip it, so it's best to skip it here. It reduces the number of strings we create and greatly reduces the size of themessages
array. This fixes #6313.