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

undefined method `broadcast_to' #212

Closed
kinsomicrote opened this issue Oct 17, 2023 · 12 comments
Closed

undefined method `broadcast_to' #212

kinsomicrote opened this issue Oct 17, 2023 · 12 comments
Assignees

Comments

@kinsomicrote
Copy link

Hello,

I have logster and redis installed in my Rails 7.1.1 app. When I start up my rails server I get the following errors;

20:21:31 sidekiq.1 | undefined method `broadcast_to' for #<Logster::DeferLogger:0x0000000114553498 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00000001145ffe28 @datetime_format=nil>, @formatter=nil, @logdev=nil, @store=#<Logster::RedisStore:0x0000000114553ad8 @max_retention=604800, @skip_empty=true, @allow_custom_patterns=false, @patterns_cache=#<Logster::Cache:0x00000001145d20b8 @age=2, @hash={}>, @redis=#<Redis client v5.0.7 for redis://localhost:6379/0>, @max_backlog=1000, @redis_prefix=nil, @redis_raw_connection=nil>, @chained=[#<ActiveSupport::BroadcastLogger:0x000000011453b500 @broadcasts=[#<ActiveSupport::Logger:0x00000001144b9438 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00000001144d6150 @datetime_format=nil>, @formatter=#<Logger::Formatter:0x00000001144d3928 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x00000001144b9ed8 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @binmode=false, @mon_data=#<Monitor:0x00000001144d5f70>, @mon_data_owner_object_id=5120>, @local_level_key=:logger_thread_safe_level_9060>], @progname="Broadcast", @formatter=#<Logger::Formatter:0x00000001144d3928 @datetime_format=nil>>], @skip_store=false, @logster_override_level_key="logster_override_level_9040">
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/rails.rb:62:in `block (2 levels) in <class:Rails>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq.rb:98:in `configure_server'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/rails.rb:53:in `block in <class:Rails>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:94:in `block in execute_hook'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:78:in `block in run_load_hooks'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:77:in `each'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:77:in `run_load_hooks'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/application/finisher.rb:93:in `block in <module:Finisher>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:32:in `instance_exec'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:32:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:61:in `block in run_initializers'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:60:in `run_initializers'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/application.rb:423:in `initialize!'
20:21:31 sidekiq.1 | /Users/jioke/lab/projects/tcnabj-mvp-api/config/environment.rb:5:in `<top (required)>'
20:21:31 sidekiq.1 | <internal:/Users/jioke/.rubies/ruby-3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
20:21:31 sidekiq.1 | <internal:/Users/jioke/.rubies/ruby-3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/cli.rb:303:in `boot_application'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/cli.rb:42:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/bin/sidekiq:31:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/sidekiq:25:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/sidekiq:25:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:23:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:492:in `exec'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:34:in `dispatch'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:28:in `start'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/exe/bundle:45:in `block in <top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/exe/bundle:33:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/bundle:25:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/bundle:25:in `<main>'
20:21:31 web.1     | Exiting
20:21:31 web.1     | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/commands/server/server_command.rb:83:in `log_to_stdout': undefined method `broadcast_to' for #<Logster::DeferLogger:0x0000000113a0b810 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000111a85518 @datetime_format=nil>, @formatter=nil, @logdev=nil, @store=#<Logster::RedisStore:0x0000000113a0be50 @max_retention=604800, @skip_empty=true, @allow_custom_patterns=false, @patterns_cache=#<Logster::Cache:0x0000000111a8a0e0 @age=2, @hash={}>, @redis=#<Redis client v5.0.7 for redis://localhost:6379/0>, @max_backlog=1000, @redis_prefix=nil, @redis_raw_connection=nil>, @chained=[#<ActiveSupport::BroadcastLogger:0x00000001111dbd90 @broadcasts=[#<ActiveSupport::Logger:0x0000000113ebd390 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000113ed9068 @datetime_format=nil>, @formatter=#<Logger::Formatter:0x0000000113ed6840 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x0000000113ebde30 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @binmode=false, @mon_data=#<Monitor:0x0000000113ed8e88>, @mon_data_owner_object_id=4760>, @local_level_key=:logger_thread_safe_level_8700>], @progname="Broadcast", @formatter=#<Logger::Formatter:0x0000000113ed6840 @datetime_format=nil>>], @skip_store=false, @logster_override_level_key="logster_override_level_8680"> (NoMethodError)
20:21:31 web.1     |
20:21:31 web.1     |           Rails.logger.broadcast_to(console)

I have no idea what I'm doing wrong. Any hints?

@etewiah
Copy link

etewiah commented Nov 3, 2023

I also got that same error after upgrading. I don't think you are doing anything wrong. I suspect it is to do with this change:

https://forum.devtalk.com/t/ruby-on-rails-v7-1-0-rc1-released/126133

I have uninstalled logster for now and hope there will be a fix soon.

@etewiah
Copy link

etewiah commented Dec 4, 2023

I wonder if people have moved on to some alternative to logster. The issue is still unresolved but doesn't seem to be generating much interest.

Also the demo is down so perhaps that too is affected:

http://logster.info/logs

@Drenmi Drenmi self-assigned this Dec 6, 2023
@etewiah
Copy link

etewiah commented Dec 6, 2023

Thanks for looking at this @Drenmi

I've found a couple of issues in the rails repo that may be related:

rails/rails#49389

rails/rails#49518

It is not exactly clear to me though what the solution would be.

@Drenmi
Copy link

Drenmi commented Dec 7, 2023

Thanks for the investigation so far, @etewiah! 🙏

Will continue looking into this.

@antarr
Copy link

antarr commented Dec 20, 2023

I wonder if people have moved on to some alternative to logster. The issue is still unresolved but doesn't seem to be generating much interest.

Also the demo is down so perhaps that too is affected:

http://logster.info/logs

Do you know of any alternatives?

@etewiah
Copy link

etewiah commented Dec 21, 2023

I don't know of an alternative that is as easy and convenient as this.

It is quite frustrating because I totally understand it is an open source project and no one is obliged to prioritise fixing it but I also don't know how to fix it myself ;(

@antarr
Copy link

antarr commented Dec 21, 2023

I don't know of an alternative that is as easy and convenient as this.

It is quite frustrating because I totally understand it is an open source project and no one is obliged to prioritise fixing it but I also don't know how to fix it myself ;(

@etewiah This patch works for me. Not sure if it breaks anything but I am still seeing messages logged in the UI.

config/initializers/logster_patch.rb

module Logster
  class DeferLogger
    def broadcast_to(loggers)
      puts "broadcasting to #{loggers}"
    end
  end
end

@etewiah
Copy link

etewiah commented Dec 21, 2023

@antarr , many thanks for that. I will give it a shot.

@chriscz
Copy link

chriscz commented Jan 10, 2024

I'm sure I'll be running into this one soon. I happened on this here as I've been having an issue where my logs are no longer going to stdout / stderr, and then I saw that Rails has this non-standard method on logs logger_outputs_to? (rails/rails#44800) which seems to in combination with logster only make the logs go to the development.log file.

@antulik
Copy link

antulik commented Feb 2, 2024

my temporary workaround

# config/initializers/logster.rb

if Rails.logger.is_a?(Logster::Logger)
  Rails.logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
end

@SamSaffron
Copy link
Member

we got to fix this seems so so so so trivial ... demo is broken due to my vps ... it auto deploys and at some point I stopped maintaining it ... will see if I can sort it out.

@Flink
Copy link
Contributor

Flink commented Feb 28, 2024

The issue is now fixed (#226) 🙂
A new version has been released too (https://rubygems.org/gems/logster/versions/2.19.0), closing this issue.

@Flink Flink closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants