Class: Rex::Logging::Sinks::TimestampFlatfile

Inherits:
Flatfile
  • Object
show all
Defined in:
lib/rex/logging/sinks/timestamp_flatfile.rb

Overview

This class implements the LogSink interface and backs it against a file on disk with a Timestamp.

Instance Attribute Summary

Attributes inherited from Flatfile

#fd

Instance Method Summary collapse

Methods inherited from Flatfile

#cleanup, #initialize

Methods included from LogSink

#cleanup, #get_current_timestamp

Constructor Details

This class inherits a constructor from Rex::Logging::Sinks::Flatfile

Instance Method Details

#log(sev, src, level, msg) ⇒ Object

:nodoc:


14
15
16
17
18
19
# File 'lib/rex/logging/sinks/timestamp_flatfile.rb', line 14

def log(sev, src, level, msg) # :nodoc:
  return unless msg.present?
  msg = msg.gsub(/\x1b\[[0-9;]*[mG]/,'').gsub(/[\x01-\x02]/, ' ').gsub(/\s+$/,'')
  fd.write("[#{get_current_timestamp}] #{msg}\n")
  fd.flush
end