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.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/syslog_tls/protocol.rb', line 38 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.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def app_name @app_name end |
#facility ⇒ Object
Returns the value of attribute facility.
30 31 32 |
# File 'lib/syslog_tls/protocol.rb', line 30 def facility @facility end |
#hostname ⇒ Object
Returns the value of attribute hostname.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def hostname @hostname end |
#msgid ⇒ Object
Returns the value of attribute msgid.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def msgid @msgid end |
#procid ⇒ Object
Returns the value of attribute procid.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def procid @procid end |
#severity ⇒ Object
Returns the value of attribute severity.
30 31 32 |
# File 'lib/syslog_tls/protocol.rb', line 30 def severity @severity end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
30 31 32 |
# File 'lib/syslog_tls/protocol.rb', line 30 def @timestamp end |
#version ⇒ Object
Returns the value of attribute version.
29 30 31 |
# File 'lib/syslog_tls/protocol.rb', line 29 def version @version end |
Instance Method Details
#assemble ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/syslog_tls/protocol.rb', line 70 def assemble [ "<#{pri}>#{.to_datetime.strftime("%b %d %H:%M:%S")}", hostname, app_name ].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.
66 67 68 |
# File 'lib/syslog_tls/protocol.rb', line 66 def pri FACILITIES[facility] * 8 + SEVERITIES[severity] end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/syslog_tls/protocol.rb', line 78 def to_s assemble end |