Class: Rex::Logging::Sinks::StdoutWithoutTimestamps

Inherits:
Stream
  • Object
show all
Defined in:
lib/rex/logging/sinks/stdout_without_timestamps.rb

Overview

This class implements the LogSink interface and backs it against stdout

Instance Attribute Summary

Attributes inherited from Stream

#stream

Instance Method Summary collapse

Methods inherited from Stream

#cleanup, #log_code_for

Methods included from LogSink

#cleanup, #get_current_timestamp

Constructor Details

#initialize(*_attrs) ⇒ StdoutWithoutTimestamps

Creates a log sink instance that will be configured to log to stdout


17
18
19
# File 'lib/rex/logging/sinks/stdout_without_timestamps.rb', line 17

def initialize(*_attrs)
  super($stdout)
end

Instance Method Details

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

Writes log data to a stream

Writes log data to a stream


27
28
29
30
31
32
33
34
35
# File 'lib/rex/logging/sinks/stdout_without_timestamps.rb', line 27

def log(sev, src, level, msg) # :nodoc:
  if sev == LOG_RAW
    stream.write(msg)
  else
    stream.write("[#{log_code_for(sev)}(#{level})] #{src}: #{msg}\n")
  end

  stream.flush
end