Class: MEE::RFC5424::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/mee/rfc5424.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = {}) ⇒ Meta

Returns a new instance of Meta.



15
16
17
18
19
20
# 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

Instance Attribute Details

#facilityObject

Returns the value of attribute facility.



13
14
15
# File 'lib/mee/rfc5424.rb', line 13

def facility
  @facility
end

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/mee/rfc5424.rb', line 13

def host
  @host
end

#pidObject

Returns the value of attribute pid.



13
14
15
# File 'lib/mee/rfc5424.rb', line 13

def pid
  @pid
end

#proc_nameObject

Returns the value of attribute proc_name.



13
14
15
# File 'lib/mee/rfc5424.rb', line 13

def proc_name
  @proc_name
end

Instance Method Details

#header(params = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/mee/rfc5424.rb', line 22

def header( params = {} )
  severity = params[:severity] || Syslog::LOG_INFO
  when_date = (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