Class: Rex::Logging::Sinks::Stderr

Inherits:
Object
  • Object
show all
Includes:
LogSink
Defined in:
lib/rex/logging/sinks/stderr.rb

Overview

This class implements the LogSink interface and backs it against stderr

Instance Method Summary collapse

Methods included from LogSink

#cleanup

Instance Method Details

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

Writes log data to stderr



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rex/logging/sinks/stderr.rb', line 18

def log(sev, src, level, msg, from) # :nodoc:
  if (sev == LOG_RAW)
    $stderr.write(msg)
  else
    code = 'i'

    case sev
      when LOG_DEBUG
        code = 'd'
      when LOG_ERROR
        code = 'e'
      when LOG_INFO
        code = 'i'
      when LOG_WARN
        code = 'w'
    end
    $stderr.write("[#{get_current_timestamp}] [#{code}(#{level})] #{src}: #{msg}\n")
  end

  $stderr.flush
end