How to Selectively Quite SQL Logging

I know about logger.silence but here is the issue: I’m comfortable with
the way the user engine is working, but it generates quite a bit of SQL
noise in the logs. I’d like, for that engine, to suppress the SQL
logging.

Code in it has return statements in conditionals, e.g.,

if !user?
  RAILS_DEFAULT_LOGGER.debug "checking guest authorisation for 

#{controller}/#{action}"
if User.guest_user_authorized?(controller, action)
yield block if block != nil
return true
end
else
RAILS_DEFAULT_LOGGER.debug “checking user:#{session[:user].id}
authorisation for #{controller}/#{action}”
if current_user.authorized?(controller, action)
yield block if block != nil
return true
end
end
return false

so… bracketing it in logger.silence do blocks may cause the logger to
remain off if the early out return statement is executed.

Suggestions for leaving SQL logging on for the app in general but off
for the user engine?

Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs