lograge icon indicating copy to clipboard operation
lograge copied to clipboard

Why logging repeated ?

Open songky opened this issue 6 years ago • 1 comments

Need help. I want to get log data in some models through ActiveSupport::Notifications.subscribe when object after created, such as

ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, unique_id, payload|
  Rails.logger.debug("[NOTIFICATION] #{name} #{start} #{finish} #{payload}")
end

But in the terminal, it still shows history log data when creating an object every time,

[NOTIFICATION] process_action.action_controller 2018-08-24 15:45:50 2018-08-24 15:45:50 {:controller=>"controller", :action=>"create", :params=>{"params"}, :format=>:json, :method=>"POST", :path=>"path", :status=>200, :view_runtime=>6.231000006664544, :db_runtime=>24.903999999999996, :remote_ip=>"127.0.0.1", :user_agent=>"user agent"} [NOTIFICATION] process_action.action_controller 2018-08-24 15:45:50 2018-08-24 15:45:50 {:controller=>"controller", :action=>"create", :params=>{"params"}, :format=>:json, :method=>"POST", :path=>"path", :status=>200, :view_runtime=>6.231000006664544, :db_runtime=>24.903999999999996, :remote_ip=>"127.0.0.1", :user_agent=>"user agent"} [NOTIFICATION] process_action.action_controller 2018-08-24 15:45:50 {:controller=>"controller", :action=>"create", :params=>{"params"}, :format=>:json, :method=>"POST", :path=>"path", :status=>200, :view_runtime=>6.231000006664544, :db_runtime=>24.903999999999996, :remote_ip=>"127.0.0.1", :user_agent=>"user agent"}

Please help, thanks.

songky avatar Aug 24 '18 07:08 songky

On Heroku you may see double logging to STDOUT at the debug log level.

Have you validated that your experience with the AS::N is related to lograge? Your code doesn't look like it has anything to do with Lograge.

bf4 avatar Aug 28 '18 08:08 bf4