Files
metasploit-gs/lib/rex/logging/sinks/timestamp_flatfile.rb
T
Brent Cook ca5bc94ccf kill never unused 'from' argument in library logs
This avoids computing a stack trace on every single log message
that is never used in any of the logging sinks. This is one of the
number one profiled memory allocation/deallocation events in Metasploit
as shown with memory_profiler.
2019-12-02 09:03:58 -06:00

23 lines
460 B
Ruby

# -*- 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) # :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
end
end end end