lib/frankenstein/server/webrick_logger.rb in frankenstein-0.2.0 vs lib/frankenstein/server/webrick_logger.rb in frankenstein-0.2.0.4.g676c8dd

- old
+ new

@@ -37,18 +37,28 @@ def initialize(logger:, progname: "WEBrick", access_log_priority: Logger::DEBUG) @logger, @progname, @priority = logger, progname, access_log_priority end %i{debug error fatal info warn}.each do |sev| - define_method(sev) do |msg, &blk| - if blk + define_method(sev) do |msg = nil, &blk| + if msg && blk + # This never happens in webrick now, but they might get the memo + # one day + @logger.__send__(sev, msg, &blk) + elsif blk + # I can't find any of these, either, but I live in hope @logger.__send__(sev, @progname, &blk) else @logger.__send__(sev, @progname) { msg } end end end + # Simulate the "append literal message" feature + # + # Nothing goes into *my* logs without having appropriate metadata attached, + # so this just funnels these messages into the proper priority-based system. + # def <<(msg) @logger.add(@priority, msg, @progname) end end end