rails_semantic_logger icon indicating copy to clipboard operation
rails_semantic_logger copied to clipboard

Sidekiq: ERROR Could not log "sql.active_record" event. ArgumentError: comparison of Symbol with 0 failed

Open PrajnaYaji18 opened this issue 3 years ago • 1 comments
trafficstars

Environment

Provide at least:

  • Ruby Version : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
  • Rails Version: Rails 5.2.4.6
  • Rails Semantic Logger Version: 4.4.4
  • Sidekiq version: 6.4.1
  • Rails configuration: N/A
  • Full Stack Trace, if an exception is being raised:
ERROR Could not log "sql.active_record" event. ArgumentError: comparison of Symbol with 0 failed ["./vendor/cache/ruby/2.7.0/gems/sidekiq-6.4.1/lib/sidekiq/logger.rb:39:in `<='", "./vendor/cache/ruby/2.7.0/gems/sidekiq-6.4.1/lib/sidekiq/logger.rb:39:in `debug?'", "./vendor/cache/ruby/2.7.0/gems/activerecord-5.2.4.6/lib/active_record/log_subscriber.rb:22:in `sql'" ...

Note:

  • Issues reported here should be related to monkey patches applied to Rails to make it use Semantic Logger.
  • For other logging and appender related issues, please report the issue at [Semantic Logger](https://github.com/reidmorrison/semantic_logger/issues.

Expected Behavior

  • Sidekiq logger should work without any exception after upgrading it from 5.2.1 to 6.4.1

Actual Behavior

  • logger is raising expection for sql queries

I think this behaviour is because Sidekiq expects logger level to be integer (https://github.com/mperham/sidekiq/blob/v6.4.1/lib/sidekiq/logger.rb#L39) but semantic logger returns it as symbol/string

PrajnaYaji18 avatar Feb 11 '22 06:02 PrajnaYaji18

That is an invalid assumption on Sidekiq's part. Nothing we can do about it here. Unless you can get sidekick to use the public apis then you will need to monkey-patch Sidekiq to make it work. The public api's use things like .debug? for checking the level.

reidmorrison avatar Mar 24 '22 14:03 reidmorrison