Skip to content
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

NoMethodError: undefined method `formatter=' #5

Closed
mhenrixon opened this issue Oct 3, 2023 · 10 comments
Closed

NoMethodError: undefined method `formatter=' #5

mhenrixon opened this issue Oct 3, 2023 · 10 comments

Comments

@mhenrixon
Copy link

TwP/logging#245

Crossposting in case you depend on twp/logging and need a version bump or something.

@zormandi
Copy link
Owner

zormandi commented Oct 4, 2023

Thanks, I'll look into it. 👍

@brandondrew
Copy link

I'm getting the error with Rails 7.0.7.2:

 undefined method `formatter=' for #<Logging::Logger:0x0000000123555d38 @name="Application", @parent=#<Logging::RootLogger:0x0000000117f18c50 @name="root", @appenders=[#<Logging::Appenders::Stdout:0x00000001229fed90 @io=#<IO:<STDOUT>>, @close_method=:close, @buffer=[], @immediate=[], @auto_flushing=1, @async=false, @async_flusher=nil, @flush_period=nil, @name="stdout", @closed=false, @filters=[], @mutex=#<ReentrantMutex:0x00000001229da878 @locker=nil>, @layout=#<Logcraft::LogLayout:0x00000001229bb8b0 @global_context={}, @formatter=#<Proc:0x0000000121a33e60 /Users/brandon/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/logcraft-2.1/lib/logcraft/log_layout.rb:7 (lambda)>, @level_formatter=#<Proc:0x0000000121a33de8 /Users/brandon/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/logcraft-2.1/lib/logcraft/log_layout.rb:8 (lambda)>>, @level=0, @encoding=#<Encoding:UTF-8>, @write_size=500>], @additive=false, @caller_tracing=false, @level=1>, @appenders=[], @additive=true, @level=1, @caller_tracing=false> (NoMethodError)

        logger.formatter = ActiveSupport::Logger::SimpleFormatter.new
              ^^^^^^^^^^^^

@zormandi
Copy link
Owner

@brandondrew I couldn't reproduce the issue with Rails 7.0.7.2. All tests run fine. Unless, of course, you're calling logger.formatter = ... explicitly, which you shouldn't do. If this is in a newly generated Rails configuration then you should remove those lines.

@zormandi
Copy link
Owner

New version is released which fixes compatibility issues with Rails 7.1.

@mhenrixon
Copy link
Author

Thank you! I'll give it a spin later today.

@mhenrixon
Copy link
Author

Seems to work like a charm so closing!

@lauer
Copy link

lauer commented Feb 13, 2024

UPDATE: Sorry, it seems to be a problem with dotenv-rails after upgrading from 2.8.1 to 3.0.0 of that gem.
and maybe its connected to use of GoodJob - bensheldon/good_job#1247

--
It seems like I have the same bug in Rails 7.1.3, after I start to use broadcast/hotwire, or maybe I have misconfigured something?

16:05:23 web.1 | /Users/jesper.laursen/.dotfiles/link/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/broadcast_logger.rb:146:in block in formatter=': undefined method formatter=' for #<Logging::Logger:0x0000000114892be0 @name="Application", @parent=#<Logging::RootLogger:0x0000000114817620 @name="root", @appenders=[#<Logging::Appenders::Stdout:0x0000000113698840 @io=#<IO:<STDOUT>>, @close_method=:close, @buffer=[], @immediate=[], @auto_flushing=1, @async=false, @async_flusher=nil, @flush_period=nil, @name="stdout", @closed=false, @filters=[], @mutex=#<ReentrantMutex:0x0000000113698340 @locker=nil>, @layout=#<Logcraft::LogLayout:0x000000011489a570 @global_context={}, @formatter=#<Proc:0x0000000113698cf0 /Users/jesper.laursen/.dotfiles/link/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/logcraft-2.2.1/lib/logcraft/log_layout.rb:7 (lambda)>, @level_formatter=#<Proc:0x0000000113698c78 /Users/jesper.laursen/.dotfiles/link/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/logcraft-2.2.1/lib/logcraft/log_layout.rb:8 (lambda)>>, @level=0, @encoding=#<Encoding:UTF-8>, @write_size=500>], @additive=false, @caller_tracing=false, @level=1>, @appenders=[], @additive=true, @level=1, @caller_tracing=false, @logdev=#<OpenStruct dev=#<IO:<STDOUT>>>> (NoMethodError)

@juna-nb
Copy link

juna-nb commented Feb 21, 2024

@lauer this change (yet un-merged) fixed the issue for me. Thanks for corroborating that it might be a dotenv issue.
bkeepers/dotenv#489

@mhenrixon
Copy link
Author

This has now been fixed in logging.

@zormandi-byborg
Copy link
Contributor

Thanks for the update. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants