Class: ActiveSupport::LogSubscriber::TestHelper::MockLogger
- Inherits:
-
Object
- Object
- ActiveSupport::LogSubscriber::TestHelper::MockLogger
- Includes:
- BufferedLogger::Severity
- Defined in:
- activesupport/lib/active_support/log_subscriber/test_helper.rb
Constant Summary
Constant Summary
Constants included from BufferedLogger::Severity
BufferedLogger::Severity::DEBUG, BufferedLogger::Severity::ERROR, BufferedLogger::Severity::FATAL, BufferedLogger::Severity::INFO, BufferedLogger::Severity::UNKNOWN, BufferedLogger::Severity::WARN
Instance Attribute Summary (collapse)
-
- (Object) flush_count
readonly
Returns the value of attribute flush_count.
-
- (Object) level
Returns the value of attribute level.
Instance Method Summary (collapse)
- - (Object) flush
-
- (MockLogger) initialize(level = DEBUG)
constructor
A new instance of MockLogger.
- - (Object) logged(level)
- - (Object) method_missing(level, message)
Constructor Details
- (MockLogger) initialize(level = DEBUG)
A new instance of MockLogger
56 57 58 59 60 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 56 def initialize(level = DEBUG) @flush_count = 0 @level = level @logged = Hash.new { |h,k| h[k] = [] } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(level, message)
62 63 64 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 62 def method_missing(level, ) @logged[level] << end |
Instance Attribute Details
- (Object) flush_count (readonly)
Returns the value of attribute flush_count
53 54 55 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 53 def flush_count @flush_count end |
- (Object) level
Returns the value of attribute level
54 55 56 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 54 def level @level end |
Instance Method Details
- (Object) flush
70 71 72 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 70 def flush @flush_count += 1 end |
- (Object) logged(level)
66 67 68 |
# File 'activesupport/lib/active_support/log_subscriber/test_helper.rb', line 66 def logged(level) @logged[level].compact.map { |l| l.to_s.strip } end |