简体   繁体   中英

Unknown logs interrupt me while `binding.pry` on Rails

I'm developing with Ruby on Rails. When I start an application server with Puma, the following logs continue to show every a few seconds.

{"method":{},"path":{},"format":{},"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"duration":8.75,"backtrace":null,"host":null,"user_id":null,"user_type":null,"remote_ip":null,"user_agent":null,"os":null,"os_version":null,"browser":null,"browser_version":null,"@timestamp":"2021-07-28T10:24:34.068Z","@version":"1","message":"[200] (ApplicationCable::Connection#connect)"}
{"method":{},"path":{},"format":{},"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"duration":0.58,"backtrace":null,"host":null,"user_id":null,"user_type":null,"remote_ip":null,"user_agent":null,"os":null,"os_version":null,"browser":null,"browser_version":null,"@timestamp":"2021-07-28T10:24:34.069Z","@version":"1","message":"[200] (ApplicationCable::Connection#disconnect)"}

This interrupts binding.pry prompts as follow, so I can't debug an application properly.

[1] pry(#<SomeController>)> {"method":{},"path":{},"format":{},"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"duration":8.75,"backtrace":null,"host":null,"user_id":null,"user_type":null,"remote_ip":null,"user_agent":null,"os":null,"os_version":null,"browser":null,"browser_version":null,"@timestamp":"2021-07-28T10:24:34.068Z","@version":"1","message":"[200] (ApplicationCable::Connection#connect)"}
{"method":{},"path":{},"format":{},"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"duration":0.58,"backtrace":null,"host":null,"user_id":null,"user_type":null,"remote_ip":null,"user_agent":null,"os":null,"os_version":null,"browser":null,"browser_version":null,"@timestamp":"2021-07-28T10:24:34.069Z","@version":"1","message":"[200] (ApplicationCable::Connection#disconnect)"}

I wasn't able to find from which these logs show.

What I've tried is adding ActionCable.server.config.logger = Logger.new(nil) to config/application.rb . But I still have the problem.

https://dev.to/xlts/fixing-rails-action-cable-logger-la8#option-2-try-to-do-it-systematically

How can I fix this problem?

Thank you in advance.

I'm using Lograge , so I've resolved this problem by adding the following configuration to config/initializers/lograge.rb .

Rails.application.configure do
  # ...
  # ...
  # ...

  config.lograge.ignore_actions = [
    "ApplicationCable::Connection#connect",
    "ApplicationCable::Connection#disconnect"
  ]
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM