From 9df5443eb2641e6b6136dc6e90337521c34f2ac1 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Sun, 25 Jun 2023 16:27:46 +0900 Subject: [PATCH] Add support for upcoming logger 1.4.3 logger 1.4.3 will have ruby/logger#85. It initializes a new instance variable in `Logger#initialize`. `Jekyll::Stevenson < ::Logger` doesn't use `super`. So the new instance variable isn't initialized in `Jekyll::Stevenson`. And it causes an exception: ```text /tmp/local/lib/ruby/3.3.0+0/logger.rb:385:in `level': undefined method `[]' for nil (NoMethodError) @level_override[Fiber.current] || @level ^^^^^^^^^^^^^^^ from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/lib/jekyll/log_adapter.rb:45:in `adjust_verbosity' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/lib/jekyll/configuration.rb:143:in `config_files' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/lib/jekyll.rb:118:in `configuration' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/lib/jekyll/command.rb:44:in `configuration_from_options' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/lib/jekyll/commands/serve.rb:83:in `block (2 levels) in init_with_program' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/jekyll-4.3.2/exe/jekyll:15:in `' from /tmp/local/bin/jekyll:25:in `load' from /tmp/local/bin/jekyll:25:in `' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli/exec.rb:58:in `load' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli/exec.rb:58:in `kernel_load' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli/exec.rb:23:in `run' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli.rb:492:in `exec' from /tmp/local/lib/ruby/3.3.0+0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' from /tmp/local/lib/ruby/3.3.0+0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' from /tmp/local/lib/ruby/3.3.0+0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli.rb:34:in `dispatch' from /tmp/local/lib/ruby/3.3.0+0/bundler/vendor/thor/lib/thor/base.rb:485:in `start' from /tmp/local/lib/ruby/3.3.0+0/bundler/cli.rb:28:in `start' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/bundler-2.5.0.dev/libexec/bundle:37:in `block in ' from /tmp/local/lib/ruby/3.3.0+0/bundler/friendly_errors.rb:117:in `with_friendly_errors' from /tmp/local/lib/ruby/gems/3.3.0+0/gems/bundler-2.5.0.dev/libexec/bundle:29:in `' from /tmp/local/bin/bundle:25:in `load' from /tmp/local/bin/bundle:25:in `
' ``` How about using `super` instead of implementing our `Jekyll::Stevenson#initialize` to reduce maintenance cost? --- lib/jekyll/stevenson.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index 4cfc7fbba874..042d689c9220 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -3,13 +3,10 @@ module Jekyll class Stevenson < ::Logger def initialize - @progname = nil - @level = DEBUG - @default_formatter = Formatter.new - @logdev = $stdout - @formatter = proc do |_, _, _, msg| + formatter = proc do |_, _, _, msg| msg.to_s end + super($stdout, formatter: formatter) end def add(severity, message = nil, progname = nil)