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

Incompatible with Rails 7.1 ? (conflating log_level and level) #44

Open
marckohlbrugge opened this issue Oct 13, 2023 · 3 comments
Open

Comments

@marckohlbrugge
Copy link

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:

ruby/lib/logdna.rb

Lines 57 to 68 in 9d33a2f

def level
@log_level
end
def level=(value)
if value.is_a? Numeric
@log_level = Resources::LOG_LEVELS[value]
return
end
@log_level = value
end

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 😞
@marckohlbrugge
Copy link
Author

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.

@leoplct
Copy link

leoplct commented Dec 1, 2023

+1 having the same issue.

@ashwin47
Copy link

ashwin47 commented Feb 8, 2024

Same issue here.

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

3 participants