Class: SyslogTls::Header
- Inherits:
-
Object
- Object
- SyslogTls::Header
- Defined in:
- lib/syslog_tls/protocol.rb
Overview
All headers by specification wrapped in single object
Constant Summary collapse
- FACILITIES =
{}
- SEVERITIES =
{}
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#facility ⇒ Object
Returns the value of attribute facility.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#msgid ⇒ Object
Returns the value of attribute msgid.
-
#procid ⇒ Object
Returns the value of attribute procid.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #assemble ⇒ Object
-
#initialize ⇒ Header
constructor
A new instance of Header.
-
#pri ⇒ Object
Priority value is calculated by first multiplying the Facility number by 8 and then adding the numerical value of the Severity.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Header
Returns a new instance of Header.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/syslog_tls/protocol.rb', line 37 def initialize @timestamp = Time.now @severity = 'INFO' @facility = 'LOCAL0' @version = 1 @hostname = NIL_VALUE @app_name = NIL_VALUE @procid = NIL_VALUE @msgid = NIL_VALUE end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
28 29 30 |
# File 'lib/syslog_tls/protocol.rb', line 28 def app_name @app_name end |
#facility ⇒ Object
Returns the value of attribute facility.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def facility @facility end |
#hostname ⇒ Object
Returns the value of attribute hostname.
28 29 30 |
# File 'lib/syslog_tls/protocol.rb', line 28 def hostname @hostname end |
#msgid ⇒ Object
Returns the value of attribute msgid.
28 29 30 |
# File 'lib/syslog_tls/protocol.rb', line 28 def msgid @msgid end |
#procid ⇒ Object
Returns the value of attribute procid.
28 29 30 |
# File 'lib/syslog_tls/protocol.rb', line 28 def procid @procid end |
#severity ⇒ Object
Returns the value of attribute severity.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def severity @severity end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def @timestamp end |
#version ⇒ Object
Returns the value of attribute version.
28 29 30 |
# File 'lib/syslog_tls/protocol.rb', line 28 def version @version end |
Instance Method Details
#assemble ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/syslog_tls/protocol.rb', line 69 def assemble [ "<#{pri}>#{version}", .to_datetime.rfc3339, hostname, app_name, procid, msgid ].join(' ') end |
#pri ⇒ Object
Priority value is calculated by first multiplying the Facility number by 8 and then adding the numerical value of the Severity.
65 66 67 |
# File 'lib/syslog_tls/protocol.rb', line 65 def pri FACILITIES[facility] * 8 + SEVERITIES[severity] end |
#to_s ⇒ Object
80 81 82 |
# File 'lib/syslog_tls/protocol.rb', line 80 def to_s assemble end |