Skip to content

Commit

Permalink
Use block.call instead of yield in Logger#add
Browse files Browse the repository at this point in the history
It makes the block argument usage explicit, as discussed at
#50 (comment)
  • Loading branch information
mehlah committed Oct 11, 2016
1 parent 11ea608 commit 913baae
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/gelf/logger.rb
Expand Up @@ -7,14 +7,11 @@ module LoggerCompatibility
# Use it like Logger#add... or better not to use at all.
def add(level, message = nil, progname = nil, &block)
progname ||= default_options['facility']
message ||= block.call unless block.nil?

if message.nil?
if block_given?
message = yield
else
message = progname
progname = default_options['facility']
end
message = progname
progname = default_options['facility']
end

message_hash = { 'facility' => progname }
Expand Down

0 comments on commit 913baae

Please sign in to comment.