I''ve been using fixture_references, and have been getting errors from
my database about incorrect values inserted. fixture_references turns
off logging by using the silence method. The present implementation gives
me no way to turn that back on temporarily without commenting out code.
I''d like to propose the patch below, or something like it.
I have tried to keep it backwards compatible. I''ve seen no other unit
tests for logging features, so I couldn''t see where to put test
logfiles.
As a consequence this has no tests, but I have used it live and it seems
to be working correctly. I''ve also written it in such a way that
boolean parameters may be avoided. Maybe it can be hammered into a
better shape before acceptance?
Thank you,
Hugh
--- activerecord-1.15.3/lib/active_record/base.rb.orig 2007-04-04
12:10:45.046875000 +0100
+++ activerecord-1.15.3/lib/active_record/base.rb 2007-07-20 11:47:22.234375000
+0100
@@ -861,9 +861,18 @@
end
end
- # Silences the logger for the duration of the block.
- def silence
- old_logger_level, logger.level = logger.level, Logger::ERROR if logger
+ # Silences the logger for the duration of the block. Accepts
+ # a parameter: true :silence, or :silent keeps it silent,
+ # anything else leaves things as they are. The default is
+ # silent, for backwards compatibility, and because it''s what
+ # you normally want.
+ # (This means one need not use obsucure boolean parameters.)
+ def silence(use_silence = true)
+ old_logger_level = logger.level if logger
+ case use_silence
+ when true, :silent, :silence
+ logger.level = Logger::ERROR if logger
+ end
yield
ensure
logger.level = old_logger_level if logger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---