lib/semantic_logger/appender/syslog.rb in semantic_logger-4.2.2 vs lib/semantic_logger/appender/syslog.rb in semantic_logger-4.3.0
- old
+ new
@@ -118,13 +118,16 @@
#
# 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, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new, options: ::Syslog::LOG_PID| ::Syslog::LOG_CONS,
+ facility: ::Syslog::LOG_USER,
+ level_map: SemanticLogger::Formatters::Syslog::LevelMap.new,
+ options: ::Syslog::LOG_PID | ::Syslog::LOG_CONS,
tcp_client: {},
- level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
+ **args,
+ &block)
@options = options
@facility = facility
@level_map = level_map
@url = url
@@ -153,19 +156,20 @@
raise 'Missing gem: net_tcp_client. This gem is required when logging over TCP. To fix this error: gem install net_tcp_client'
end
end
end
- super(level: level, formatter: formatter, filter: filter, application: application, host: host, &block)
+ super(**args, &block)
reopen
end
# After forking an active process call #reopen to re-open
# open the handles to resources
def reopen
case @protocol
when :syslog
- ::Syslog.open(application, options, facility)
+ method = ::Syslog.opened? ? :reopen : :open
+ ::Syslog.send(method, application, options, facility)
when :tcp
# Use the local logger for @remote_syslog so errors with the remote logger can be recorded locally.
@tcp_client_options[:logger] = logger
@tcp_client_options[:server] = "#{@server}:#{@port}"
@remote_syslog = Net::TCPClient.new(@tcp_client_options)