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
-
#initialize(formatter: Loog::SHORT) ⇒ Buffer
constructor
A new instance of Buffer.
- #to_s ⇒ Object
Constructor Details
#initialize(formatter: Loog::SHORT) ⇒ Buffer
Returns a new instance of Buffer.
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/loog.rb', line 96 def initialize(formatter: Loog::SHORT) super( $stdout, level: Logger::DEBUG, formatter: proc do |severity, time, target, msg| @lines.push(formatter.call(severity, time, target, msg)) '' end ) @lines = [] end |
Instance Method Details
#to_s ⇒ Object
108 109 110 |
# File 'lib/loog.rb', line 108 def to_s @lines.map { |s| s.dup.force_encoding('UTF-8') }.join end |