Class: MEE::RFC5424::Meta
- Inherits:
-
Object
- Object
- MEE::RFC5424::Meta
- Defined in:
- lib/mee/rfc5424.rb
Instance Attribute Summary collapse
-
#facility ⇒ Object
Returns the value of attribute facility.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#proc_name ⇒ Object
Returns the value of attribute proc_name.
Instance Method Summary collapse
- #header(params = {}) ⇒ Object
-
#initialize(props = {}) ⇒ Meta
constructor
A new instance of Meta.
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
#facility ⇒ Object
Returns the value of attribute facility.
13 14 15 |
# File 'lib/mee/rfc5424.rb', line 13 def facility @facility end |
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/mee/rfc5424.rb', line 13 def host @host end |
#pid ⇒ Object
Returns the value of attribute pid.
13 14 15 |
# File 'lib/mee/rfc5424.rb', line 13 def pid @pid end |
#proc_name ⇒ Object
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 |