ruby
ruby copied to clipboard
Incompatible with Rails 7.1 ? (conflating `log_level` and `level`)
I recently tried upgrading to Rails 7.1, but this gem seems to be causing an error:
ArgumentError: comparison of String with 0 failed
The issue does not occur after removing the logdna
gem from my app.
I believe the issue is caused by Rails.logger.level
returning a string (e.g. INFO
) whereas Rails expects it to be an integer. See the Rails docs here: https://guides.rubyonrails.org/v7.1/debugging_rails_applications.html#log-levels
The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, corresponding to the log level numbers from 0 up to 5, respectively. […]
It seems like the logdna gem is conflating log_level
and level
:
https://github.com/logdna/ruby/blob/9d33a2ff31700034e3949320a8875637fefd0b39/lib/logdna.rb#L57-L68
Full stack trace:
Oct 13 04:25:16 PM rake aborted!
Oct 13 04:25:16 PM ArgumentError: comparison of String with 0 failed
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/log_subscriber.rb:140:in `>'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/log_subscriber.rb:140:in `silenced?'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `block (2 levels) in groups_for'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `reject'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `block in groups_for'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:202:in `each'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:202:in `groups_for'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:232:in `initialize'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:271:in `new'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:271:in `build_handle'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/instrumenter.rb:79:in `build_handle'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/instrumenter.rb:55:in `instrument'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1134:in `log'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:51:in `raw_execute'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:519:in `internal_execute'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:245:in `client_min_messages='
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1002:in `configure_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:693:in `block (2 levels) in reconnect!'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:374:in `reset_transaction'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:691:in `block in reconnect!'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:684:in `reconnect!'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:788:in `verify!'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:795:in `connect!'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:997:in `block in with_raw_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:996:in `with_raw_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1104:in `valid_raw_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:619:in `get_database_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:374:in `database_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:70:in `database_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:200:in `database_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:871:in `database_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:647:in `check_version'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:675:in `new_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:720:in `checkout_new_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:699:in `try_to_checkout_new_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:657:in `acquire_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:246:in `retrieve_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_handling.rb:287:in `retrieve_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_handling.rb:254:in `connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/tasks/database_tasks.rb:510:in `migration_connection'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/tasks/database_tasks.rb:243:in `migrate'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/strong_migrations-1.6.3/lib/strong_migrations/database_tasks.rb:5:in `migrate'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/railties/databases.rake:93:in `block (2 levels) in <main>'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/bugsnag-6.26.0/lib/bugsnag/integrations/rake.rb:20:in `execute'
Oct 13 04:25:16 PM /opt/render/project/.gems/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Oct 13 04:25:16 PM /opt/render/project/.gems/bin/bundle:113:in `load'
Oct 13 04:25:16 PM /opt/render/project/.gems/bin/bundle:113:in `<main>'
Oct 13 04:25:16 PM Tasks: TOP => db:migrate
Oct 13 04:25:16 PM (See full trace by running task with --trace)
Oct 13 04:25:16 PM ==> Build failed 😞
Here's the relevant change in Rails 7.1: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#rails-logger-now-returns-an-activesupport-broadcastlogger-instance
I don't think this change is supposed to be a breaking change, but it simply surfaces an underyling issue in logdna
that went unnoticed before.
+1 having the same issue.
Same issue here.