class MEE::RFC5424::Meta

Attributes

facility[RW]
host[RW]
pid[RW]
proc_name[RW]
when[RW]

Public Class Methods

new( props = {}) click to toggle source
# File lib/mee/rfc5424.rb, line 15
def initialize( props = {})
        self.host = props[:host] || Socket.gethostname
        self.proc_name = props[:name] || "ruby"
        self.facility = Syslog::Facility::LOG_USER
        self.pid = Process.pid
end

Public Instance Methods

header( params = {} ) click to toggle source
# File lib/mee/rfc5424.rb, line 22
def header( params = {} )
        severity = params[:severity] || Syslog::LOG_INFO
        when_date = (@when || (params[:when] || DateTime.now) ).new_offset( 0 )
        formatted_when = when_date.strftime("%FT%T.%3NZ")
        priority = (facility * 8) + severity
        "<#{priority}>1 #{formatted_when} #{self.host} #{proc_name} #{self.pid} - - \xEF\xBB\xBF"
end