Class: SemanticLogger::Formatters::SyslogCee
- Defined in:
- lib/semantic_logger/formatters/syslog_cee.rb
Instance Attribute Summary collapse
-
#facility ⇒ Object
Returns the value of attribute facility.
-
#level_map ⇒ Object
Returns the value of attribute level_map.
Attributes inherited from Raw
#hash, #log, #logger, #time_key
Attributes inherited from Base
Instance Method Summary collapse
- #call(log, logger) ⇒ Object
-
#initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new) ⇒ SyslogCee
constructor
CEE JSON Syslog format Untested prototype code.
-
#time ⇒ Object
Time is part of the syslog packet and is not included in the formatted message.
Methods inherited from Raw
#application, #duration, #exception, #host, #level, #message, #metric, #name, #named_tags, #payload, #process_info, #tags
Methods inherited from Base
#backtrace, #fast_tag, #level, #level=, #log, #measure, #payload, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags, #with_payload
Constructor Details
#initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new) ⇒ SyslogCee
CEE JSON Syslog format
Untested prototype code. Based on documentation only.
If this works for you, please let us know by opening an issue.
Parameters:
facility: [Integer]
Default: ::Syslog::LOG_USER
level_map: [Hash | SemanticLogger::Formatters::Syslog::LevelMap]
Supply a custom map of SemanticLogger levels to syslog levels.
Example:
# Log via udp to a remote syslog server on host: `server1` and port `8514`, using the CEE format.
SemanticLogger.add_appender(appender: :syslog, formatter: syslog_cee, url: 'udp://server1:8514')
26 27 28 29 30 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 26 def initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new) @facility = facility @level_map = level_map.is_a?(SemanticLogger::Formatters::Syslog::LevelMap) ? level_map : SemanticLogger::Formatters::Syslog::LevelMap.new(level_map) super() end |
Instance Attribute Details
#facility ⇒ Object
Returns the value of attribute facility.
10 11 12 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 10 def facility @facility end |
#level_map ⇒ Object
Returns the value of attribute level_map.
10 11 12 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 10 def level_map @level_map end |
Instance Method Details
#call(log, logger) ⇒ Object
36 37 38 39 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 36 def call(log, logger) hash = super(log, logger) create_syslog_packet("@cee: #{hash.to_json}") end |
#time ⇒ Object
Time is part of the syslog packet and is not included in the formatted message.
33 34 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 33 def time end |