Add the logsink
parent
64449d5035
commit
50cd15c52a
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: binary -*-
|
||||
module Rex
|
||||
module Logging
|
||||
module Sinks
|
||||
|
||||
###
|
||||
#
|
||||
# This class implements the LogSink interface and backs it against a
|
||||
# file on disk with a Timestamp.
|
||||
#
|
||||
###
|
||||
class TimestampFlatfile < Flatfile
|
||||
|
||||
def log(sev, src, level, msg, from) # :nodoc:
|
||||
cleaned = msg.gsub(/\x1b\[[0-9;]*[mG]/,'')
|
||||
fd.write("[#{get_current_timestamp}] #{src}: #{cleaned}\n")
|
||||
fd.flush
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end end end
|
Loading…
Reference in New Issue