require 'time' module SoarAuditingFormatter FORMAT="%s,%s,%s,%s" unless defined? FORMAT; FORMAT.freeze OPTIONAL_FIELD_FORMAT = "[%s:%s]" unless defined? OPTIONAL_FIELD_FORMAT; OPTIONAL_FIELD_FORMAT.freeze class Formatter def self.format(level, flow_id, timestamp, message) times = Time.parse(timestamp.to_s).utc.iso8601(3) sprintf(FORMAT, level, flow_id, times, message) end def self.optional_field_format(key, value) sprintf(OPTIONAL_FIELD_FORMAT, key, value) end end end