Double-logging
jpr5 opened this issue · comments
The code that hooks log
invokes super
twice -- once to check respond_to?()
and once for the call itself:
def log(str)
if super.respond_to?(:log)
super(str) unless str == 'Use Ctrl-C to stop'
else
puts(str)
end
end
Problem is, calling super
without arguments is invoking the method with the methods args by default. So, the consequence is a double-log.
It's not as "clean" per se, but one possible "right" answer is:
def log(str)
super(str) rescue puts(str) unless str == 'Use Ctrl-C to stop'
end
Tested manually and seems to do the job.
For anyone finding this, the monkey-patch to fix this behavior (until the gem is updated) is to add the following lines to your puma.rb
(Configuration DSL):
Puma::Single.class_eval do def log(str) @log_writer.log(str) unless str == "Use Ctrl-C to stop" end end
Puma::Cluster.class_eval do def log(str) @log_writer.log(str) unless str == "Use Ctrl-C to stop" end end
Cheers.