Class: Epilog::MockLogger
- Inherits:
-
Logger
- Object
- Logger
- Epilog::MockLogger
- Defined in:
- lib/epilog/mock_logger.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#add(severity, message = nil, progname = nil) ⇒ Object
(also: #log)
rubocop:disable MethodLength.
- #freeze_time(time) ⇒ Object
-
#initialize ⇒ MockLogger
constructor
A new instance of MockLogger.
- #reopen(_logdev = nil) ⇒ Object
- #reset ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ MockLogger
Returns a new instance of MockLogger.
5 6 7 8 |
# File 'lib/epilog/mock_logger.rb', line 5 def initialize super(nil) reset end |
Instance Method Details
#[](index) ⇒ Object
33 34 35 |
# File 'lib/epilog/mock_logger.rb', line 33 def [](index) @logs[index].dup || [] end |
#add(severity, message = nil, progname = nil) ⇒ Object Also known as: log
rubocop:disable MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/epilog/mock_logger.rb', line 11 def add(severity, = nil, progname = nil) severity ||= Logger::UNKNOWN return true if severity < level prog ||= progname if .nil? if block_given? = yield else = prog prog = progname end end write(format_severity(severity), current_time, prog, ) end |
#freeze_time(time) ⇒ Object
41 42 43 |
# File 'lib/epilog/mock_logger.rb', line 41 def freeze_time(time) @time = time end |
#reopen(_logdev = nil) ⇒ Object
30 31 |
# File 'lib/epilog/mock_logger.rb', line 30 def reopen(_logdev = nil) end |
#reset ⇒ Object
45 46 47 |
# File 'lib/epilog/mock_logger.rb', line 45 def reset @logs = [] end |
#to_a ⇒ Object
37 38 39 |
# File 'lib/epilog/mock_logger.rb', line 37 def to_a (0...@logs.size).map { |i| self[i] } end |