Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to silence the call to a rails controller's action all together

I've figured out how to silence the contents of an action by wrapping everything inside the action's method in a logger.silence block.

However, I still get the call to the action showing up in the log file.

I.E:

Processing DashboardController#update (for 66.201.17.166 at 2009-09-09 19:03:27) [GET]
  Parameters: {"todos"=>{"user"=>"25", "sfu_type"=>""}}
Completed in 1021ms (View: 439, DB: 438) | 200 OK [http://my.host.com/dashboard/update?todos%5Buser%5D=25&todos%5Bsfu_type%5D=]

I want to either keep the above from getting written to the logs all together, or redirect it to a different log file (i.e. dashboard.log) so it stops cluttering up the production.log file.

I get the above sample written to the log each time the ajax call updates for each user logged in. This updates about every 2 minutes so the production log file is getting flooded with unuseful log messages.

like image 396
Streamline Avatar asked Dec 30 '22 15:12

Streamline


1 Answers

Late answer, but I spent quite a bit of time of the interwebs looking for the answer, which is thus:

In the controller that contains the action you would like to ignore, override the logger method and return the rails default for some actions, and a custom logger or nil for the ones that need special handling.

def logger
  if params[:action] == 'action_to_ignore'
    # return custom logger or nil
  else
    RAILS_DEFAULT_LOGGER
  end
end

I suspect there is an easier way, and would love to hear it if it exists.

like image 97
KalaATX Avatar answered Jan 05 '23 16:01

KalaATX