lib/semantic_logger/formatters/syslog.rb in semantic_logger-4.7.1 vs lib/semantic_logger/formatters/syslog.rb in semantic_logger-4.7.2

- old
+ new

@@ -5,11 +5,11 @@ end module SemanticLogger module Formatters class Syslog < Default - attr_accessor :level_map, :facility + attr_accessor :level_map, :facility, :max_size # Default level map for every log level # # :fatal => ::Syslog::LOG_CRIT - "A critical condition has occurred" # :error => ::Syslog::LOG_ERR - "An error occurred" @@ -48,13 +48,14 @@ # 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}) - def initialize(facility: ::Syslog::LOG_USER, level_map: LevelMap.new) + def initialize(facility: ::Syslog::LOG_USER, level_map: LevelMap.new, max_size: Integer) @facility = facility @level_map = level_map.is_a?(LevelMap) ? level_map : LevelMap.new(level_map) + @max_size = max_size super() end # Time is part of the syslog packet and is not included in the formatted message. def time @@ -75,10 +76,10 @@ packet.facility = facility packet.tag = logger.application.delete(" ") packet.content = message packet.time = log.time packet.severity = level_map[log.level] - packet.to_s + packet.assemble(@max_size) end end end end