Class: Rex::Logging::Sinks::TimestampColorlessFlatfile

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

Overview

This class implements the LogSink interface and backs it against a file on disk. The logged messages will have their colors and trailing whitespace removed

Instance Attribute Summary

Attributes inherited from Stream

#stream

Instance Method Summary collapse

Methods inherited from Flatfile

#initialize

Methods inherited from Stream

#cleanup, #initialize, #log_code_for

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:


16
17
18
19
20
21
22
23
# File 'lib/rex/logging/sinks/timestamp_colorless_flatfile.rb', line 16

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