class Hoodoo::Logger::FileWriter
Writes unstructured messages to a file. Hoodoo::Logger::SlowWriter
subclass. See also Hoodoo::Logger
.
Public Class Methods
new( pathname )
click to toggle source
Create a file writer instance. Files are written by opening, adding a log message and closing again, to provide reliability. For this reason, this is a Hoodoo::Logger::SlowWriter
subclass.
If you want faster file access at the expense of immediate updates / reliability due to buffering, open a file externally to create an I/O stream and pass this persistently-open file’s stream to an Hoodoo::Logger::StreamWriter
class instead.
pathname
-
Full pathname of a file that can be opened in “ab” (append for writing at end-of-file) mode.
# File lib/hoodoo/logger/writers/file_writer.rb, line 32 def initialize( pathname ) @pathname = pathname end
Public Instance Methods
report( log_level, component, code, data )
click to toggle source
See Hoodoo::Logger::WriterMixin#report
.
# File lib/hoodoo/logger/writers/file_writer.rb, line 38 def report( log_level, component, code, data ) File.open( @pathname, 'ab' ) do | file | file.puts( flatten( log_level, component, code, data ) ) end end