Class: Sysloggly::Formatters::SyslogFormatter
- Inherits:
-
SimpleFormatter
- Object
- SimpleFormatter
- Sysloggly::Formatters::SyslogFormatter
- Defined in:
- lib/sysloggly/formatters/syslog_formatter.rb
Instance Attribute Summary
Attributes inherited from SimpleFormatter
Instance Method Summary collapse
-
#call(severity, datetime, progname, payload) ⇒ Object
Generate a syslog compat message See RFC3164 4.1.1 - 4.1.3.
-
#pri(severity) ⇒ Object
Syslog specific PRI calculation.
Methods inherited from SimpleFormatter
#datetime_format, #hashify_message, #initialize
Constructor Details
This class inherits a constructor from Sysloggly::Formatters::SimpleFormatter
Instance Method Details
#call(severity, datetime, progname, payload) ⇒ Object
Generate a syslog compat message See RFC3164 4.1.1 - 4.1.3
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sysloggly/formatters/syslog_formatter.rb', line 26 def call(severity, datetime, progname, payload) = "<#{pri(severity)}>#{datetime.strftime(datetime_format)} #{@hostname} " # Include process ID in progname/log tag - RFC3164 § 5.3 << "#{@progname || progname || $0}[#{Process.pid}]: " << MultiJson.dump((payload).merge()) << "\r\n" if ["file", "tcp"].include?(@input_uri.scheme) end |
#pri(severity) ⇒ Object
Syslog specific PRI calculation. See RFC3164 4.1.1
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sysloggly/formatters/syslog_formatter.rb', line 6 def pri(severity) severity_value = case severity when "FATAL" 0 when "ERROR" 3 when "WARN" 4 when "INFO" 6 when "DEBUG" 7 end (@facility << 3) + severity_value end |