lib/semantic_logger/appender/syslog.rb in semantic_logger-4.7.1 vs lib/semantic_logger/appender/syslog.rb in semantic_logger-4.7.2
- old
+ new
@@ -29,11 +29,11 @@
# )
#
module SemanticLogger
module Appender
class Syslog < SemanticLogger::Subscriber
- attr_reader :remote_syslog, :url, :server, :port, :protocol, :facility, :options, :level_map
+ attr_reader :remote_syslog, :url, :server, :port, :protocol, :facility, :options, :level_map, :max_size
# Create a Syslog appender instance.
#
# Parameters
# url: [String]
@@ -71,10 +71,14 @@
#
# application: [String]
# Identity of the program.
# Default: SemanticLogger.application
#
+ # max_size: [Integer]
+ # Set your own packet size.
+ # Default: 1024 bytes
+ #
# options: [Integer]
# Default: ::Syslog::LOG_PID | ::Syslog::LOG_CONS
# Any of the following (options can be logically OR'd together)
# ::Syslog::LOG_CONS
# ::Syslog::LOG_NDELAY
@@ -119,18 +123,20 @@
# 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(url: "syslog://localhost",
facility: ::Syslog::LOG_USER,
+ max_size: 1024,
level_map: SemanticLogger::Formatters::Syslog::LevelMap.new,
options: ::Syslog::LOG_PID | ::Syslog::LOG_CONS,
tcp_client: {},
**args,
&block)
@options = options
@facility = facility
+ @max_size = max_size
@level_map = level_map
@url = url
uri = URI(@url)
@server = uri.host || "localhost"
@protocol = (uri.scheme || :syslog).to_sym
@@ -207,10 +213,10 @@
def default_formatter
if protocol == :syslog
# Format is text output without the time
SemanticLogger::Formatters::Default.new(time_format: nil)
else
- SemanticLogger::Formatters::Syslog.new(facility: facility, level_map: level_map)
+ SemanticLogger::Formatters::Syslog.new(facility: facility, level_map: level_map, max_size: max_size)
end
end
end
end
end