Class: Loog::Buffer
- Inherits:
-
Logger
- Object
- Logger
- Loog::Buffer
- Defined in:
- lib/loog.rb
Overview
Accumulator of everything. This class may be used for testing, when it's necessary to accumulate all log messages in one place and then "assert" the presence of certain strings inside them.
Instance Method Summary collapse
Constructor Details
#initialize(level: Logger::DEBUG, formatter: Loog::SHORT) ⇒ Buffer
Ctor
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/loog.rb', line 83 def initialize(level: Logger::DEBUG, formatter: Loog::SHORT) super( $stdout, level: level, formatter: proc do |severity, time, target, msg| @lines.push(formatter.call(severity, time, target, msg)) '' end ) @lines = [] end |
Instance Method Details
#to_s ⇒ Object
95 96 97 |
# File 'lib/loog.rb', line 95 def to_s @lines.map { |s| s.dup.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') }.join end |