Sha256: e31d179a0db60da7775d2fab5d1864a899bad1d2ab69c4b49b213c08a29833d7
Contents?: true
Size: 1.91 KB
Versions: 4
Compression:
Stored size: 1.91 KB
Contents
module LogStasher class Railtie < ::Rails::Railtie config.logstasher = ::ActiveSupport::OrderedOptions.new config.logstasher.enabled = false config.logstasher.include_parameters = true config.logstasher.serialize_parameters = true config.logstasher.silence_standard_logging = false config.logstasher.logger = nil config.logstasher.log_level = ::Logger::INFO initializer 'logstasher.configure' do options = config.logstasher ::LogStasher.enabled = options.enabled ::LogStasher.include_parameters = options.include_parameters ::LogStasher.serialize_parameters = options.serialize_parameters ::LogStasher.silence_standard_logging = options.silence_standard_logging ::LogStasher.logger = options.logger || default_logger ::LogStasher.logger.level = options.log_level end initializer 'logstasher.load' do if ::LogStasher.enabled? ::ActiveSupport.on_load(:action_controller) do require 'logstasher/log_subscriber' require 'logstasher/context_wrapper' include ::LogStasher::ContextWrapper end end end config.after_initialize do if ::LogStasher.enabled? && ::LogStasher.silence_standard_logging? require 'logstasher/silent_logger' ::Rails::Rack::Logger.send(:include, ::LogStasher::SilentLogger) ::ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber| if subscriber.is_a?(::ActiveSupport::LogSubscriber) subscriber.class.send(:include, ::LogStasher::SilentLogger) end end end end def default_logger unless @default_logger path = ::Rails.root.join('log', "logstasher.log") ::FileUtils.touch(path) # prevent autocreate messages in log @default_logger = ::Logger.new(path) end @default_logger end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rv-logstasher-1.5.0 | lib/logstasher/railtie.rb |
rv-logstasher-1.4.0 | lib/logstasher/railtie.rb |
rv-logstasher-1.3.2 | lib/logstasher/railtie.rb |
rv-logstasher-1.3.1 | lib/logstasher/railtie.rb |