lib/logstasher/railtie.rb in logstasher-2.1.1 vs lib/logstasher/railtie.rb in logstasher-2.1.2

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'rails/railtie' require 'action_view/log_subscriber' require 'action_controller/log_subscriber' require 'socket' @@ -18,11 +20,11 @@ # Try loading the config/logstasher.yml if present env = Rails.env.to_sym || :development config_file = File.expand_path './config/logstasher.yml' # Load and ERB templating of YAML files - LOGSTASHER = File.exist?(config_file) ? YAML.load(ERB.new(File.read(config_file)).result).symbolize_keys : nil + LOGSTASHER = File.exist?(config_file) ? YAML.safe_load(ERB.new(File.read(config_file)).result).symbolize_keys : nil initializer :logstasher, before: :load_config_initializers do |app| if LOGSTASHER.present? # process common configs LogStasher.process_config(app.config.logstasher, LOGSTASHER) @@ -40,11 +42,11 @@ LogStasher.setup(config.logstasher) if config.logstasher.enabled end end def rack_cache_hashlike?(app) - app.config.action_dispatch.rack_cache && app.config.action_dispatch.rack_cache.respond_to?(:[]=) + app.config.action_dispatch.rack_cache&.respond_to?(:[]=) end end def default_source case RUBY_PLATFORM @@ -53,10 +55,10 @@ # hostnames that even as real hostnames without the `.local` part, # are still unresolvable. One reliable way to get an IP is to # get all available IP address lists and use the first one. # This will always be `127.0.0.1`. address_info = Socket.ip_address_list.first - address_info && address_info.ip_address + address_info&.ip_address else IPSocket.getaddress(Socket.gethostname) end end