lib/semantic_logger/appender/syslog.rb in semantic_logger-4.2.0 vs lib/semantic_logger/appender/syslog.rb in semantic_logger-4.2.1

- old
+ new

@@ -118,11 +118,11 @@ # # 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) @options = options @facility = facility @@ -133,14 +133,14 @@ @protocol = (uri.scheme || :syslog).to_sym @port = uri.port || 514 @server = 'localhost' if @protocol == :syslog @tcp_client_options = tcp_client - raise "Unknown protocol #{@protocol}!" unless [:syslog, :tcp, :udp].include?(@protocol) + raise "Unknown protocol #{@protocol}!" unless %i[syslog tcp udp].include?(@protocol) # The syslog_protocol gem is required when logging over TCP or UDP. - if [:tcp, :udp].include?(@protocol) + if %i[tcp udp].include?(@protocol) begin require 'syslog_protocol' rescue LoadError raise 'Missing gem: syslog_protocol. This gem is required when logging over TCP or UDP. To fix this error: gem install syslog_protocol' end @@ -194,11 +194,11 @@ true end # Flush is called by the semantic_logger during shutdown. def flush - @remote_syslog.flush if @remote_syslog && @remote_syslog.respond_to?(:flush) + @remote_syslog.flush if @remote_syslog&.respond_to?(:flush) end # Returns [SemanticLogger::Formatters::Base] default formatter for this Appender depending on the protocal selected def default_formatter if protocol == :syslog @@ -206,9 +206,8 @@ SemanticLogger::Formatters::Default.new(time_format: nil) else SemanticLogger::Formatters::Syslog.new(facility: facility, level_map: level_map) end end - end end end