Class: Hoodoo::Logger::StreamWriter
- Inherits:
-
FastWriter
- Object
- FastWriter
- Hoodoo::Logger::StreamWriter
- Includes:
- FlattenerMixin
- Defined in:
- lib/hoodoo/logger/writers/stream_writer.rb
Overview
Writes unstructured messages to (presumed) fast output streams such as $stdout
. Hoodoo::Logger::FastWriter subclass. See also Hoodoo::Logger.
Instance Method Summary collapse
-
#initialize(output_stream = $stdout) ⇒ StreamWriter
constructor
Create a stream writer instance.
-
#report(log_level, component, code, data) ⇒ Object
See Hoodoo::Logger::WriterMixin#report.
Methods included from FlattenerMixin
Constructor Details
#initialize(output_stream = $stdout) ⇒ StreamWriter
Create a stream writer instance. Although you could initialize this class with a slow output stream, they’re expected to be fast (e.g. terminal output) as this is a Hoodoo::Logger::FastWriter subclass.
For reliable file writing, use the Hoodoo::Logger::FileWriter class instead.
output_stream
-
Optional I/O stream instance; default is $stdout. The instance must provide a
puts
implementation.
32 33 34 |
# File 'lib/hoodoo/logger/writers/stream_writer.rb', line 32 def initialize( output_stream = $stdout ) @output_stream = output_stream end |
Instance Method Details
#report(log_level, component, code, data) ⇒ Object
See Hoodoo::Logger::WriterMixin#report.
38 39 40 |
# File 'lib/hoodoo/logger/writers/stream_writer.rb', line 38 def report( log_level, component, code, data ) @output_stream.puts( flatten( log_level, component, code, data ) ) end |