Class: SemanticLogger::Formatters::Syslog
- Defined in:
- lib/semantic_logger/formatters/syslog.rb
Defined Under Namespace
Classes: LevelMap
Constant Summary
Constants inherited from Base
Base::PRECISION, Base::TIME_FORMAT
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 Default
Attributes inherited from Base
#log_application, #log_host, #time_format
Instance Method Summary collapse
- #call(log, logger) ⇒ Object
-
#initialize(facility: ::Syslog::LOG_USER, level_map: LevelMap.new) ⇒ Syslog
constructor
Create a Syslog Log Formatter.
-
#time ⇒ Object
Time is part of the syslog packet and is not included in the formatted message.
Methods inherited from Default
#duration, #exception, #level, #message, #name, #named_tags, #payload, #process_info, #tags
Constructor Details
#initialize(facility: ::Syslog::LOG_USER, level_map: LevelMap.new) ⇒ Syslog
Create a Syslog Log Formatter
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:
# Change the warn level to LOG_NOTICE level instead of a the default of LOG_WARNING.
SemanticLogger.add_appender(appender: :syslog, level_map: {warn: ::Syslog::LOG_NOTICE})
53 54 55 56 57 |
# File 'lib/semantic_logger/formatters/syslog.rb', line 53 def initialize(facility: ::Syslog::LOG_USER, level_map: LevelMap.new) @facility = facility @level_map = level_map.is_a?(LevelMap) ? level_map : 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.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.rb', line 10 def level_map @level_map end |
Instance Method Details
#call(log, logger) ⇒ Object
64 65 66 67 |
# File 'lib/semantic_logger/formatters/syslog.rb', line 64 def call(log, logger) = super(log, logger) create_syslog_packet() end |
#time ⇒ Object
Time is part of the syslog packet and is not included in the formatted message.
60 61 62 |
# File 'lib/semantic_logger/formatters/syslog.rb', line 60 def time nil end |