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.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
Attributes inherited from Raw
Attributes inherited from Base
Instance Method Summary collapse
- #call(log, logger) ⇒ Object
-
#initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new, max_size: Integer) ⇒ 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, #environment, #exception, #file_name_and_line, #host, #level, #message, #metric, #name, #named_tags, #payload, #pid, #tags, #thread_name
Methods inherited from Base
#backtrace, #fast_tag, #level, #level=, #log, #measure, #named_tags, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags
Constructor Details
#initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new, max_size: Integer) ⇒ 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')
27 28 29 30 31 32 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 27 def initialize(facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new, max_size: Integer) @facility = facility @level_map = level_map.is_a?(SemanticLogger::Formatters::Syslog::LevelMap) ? level_map : SemanticLogger::Formatters::Syslog::LevelMap.new(level_map) @max_size = max_size super() end |
Instance Attribute Details
#facility ⇒ Object
Returns the value of attribute facility.
11 12 13 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 11 def facility @facility end |
#level_map ⇒ Object
Returns the value of attribute level_map.
11 12 13 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 11 def level_map @level_map end |
#max_size ⇒ Object
Returns the value of attribute max_size.
11 12 13 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 11 def max_size @max_size end |
Instance Method Details
#call(log, logger) ⇒ Object
38 39 40 41 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 38 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.
35 36 |
# File 'lib/semantic_logger/formatters/syslog_cee.rb', line 35 def time end |