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
--
Posted via http://www.ruby-forum.com/.
Oops ... should have been "quiet." -- Posted via http://www.ruby-forum.com/.
If your logger level is set above debug, you shouldn''t see the messages output in the fragment you''ve posted.... does that sound like a reasonable solution? There is a fair peppering of the user engine (and engines plugin) code at the moment with logger statements, so I do appreciate the issue. - james On 1/12/06, Steve Ross <cwdinfo@gmail.com> wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Setting the logger level above debug would be fine, except there''s a fair peppering of logger statements in *my* code as well :) I figured if it was easy, it would have been done. This is a problem not just for engines, but also for plugins and components. It would be cool if there were some hook that allowed for logging levels to be adjusted before and after some of these things. Hmmmmm... I wonder whether an around_filter might work? -- Posted via http://www.ruby-forum.com/.