Module: Hubbado::Log::Logger::Substitute
- Defined in:
- lib/hubbado/log/logger/substitute.rb
Overview
What a logger was told rather than what it wrote. Extended onto a mimic of Logger, so a class under test is handed something that answers as a logger and keeps what it was given.
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
-
#logged(severity = nil) ⇒ Object
Everything about what a class said, in order.
-
#logged?(severity = nil) ⇒ Boolean
Whether, where #logged and #messages ask what.
-
#messages(severity = nil) ⇒ Object
What a class said, where #logged is everything about it.
Instance Method Details
#logged(severity = nil) ⇒ Object
Everything about what a class said, in order. Named with a severity, only what it said at that one.
A severity reaches a logger two ways: as the method, from the generated severity methods, or as #log's first argument. Both are compared as symbols, because #log takes a String as readily and passes on what it was given.
15 16 17 18 19 20 21 |
# File 'lib/hubbado/log/logger/substitute.rb', line 15 def logged(severity = nil) entries = invocations.map { |invocation| entry(invocation) } return entries if severity.nil? entries.select { |entry| entry.severity == severity.to_s.to_sym } end |
#logged?(severity = nil) ⇒ Boolean
Whether, where #logged and #messages ask what. Without a severity, whether anything was written at all.
28 |
# File 'lib/hubbado/log/logger/substitute.rb', line 28 def logged?(severity = nil) = !logged(severity).empty? |
#messages(severity = nil) ⇒ Object
What a class said, where #logged is everything about it.
24 |
# File 'lib/hubbado/log/logger/substitute.rb', line 24 def (severity = nil) = logged(severity).map(&:message) |