logstasher 1.4.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc18d114cfc41499a37e388cc18a1cf2608ba935e629d6dd7c4bf6f9382bdbf1
4
- data.tar.gz: 38646241250be07048968e31e807a5683b7342916d018220eb961465ca014307
3
+ metadata.gz: 653599eb3d27e38a3c68adfb9cacd8f2d363b36190c7f04691e651bb0d819622
4
+ data.tar.gz: 5adb9b7b17cb656bc8261e6a873144d313e2e5cecf47b5061e4843de7de18eb3
5
5
  SHA512:
6
- metadata.gz: 26124c87a8d13d71b0551d79d599eda734c656ad38576895adb59b36d1a093dc350a2a26287f373ecc3dd7782eee1ce4d78ef59a833ca791ce019c940d50e9da
7
- data.tar.gz: 02acf571115949f295ff1dd654549bfa8d296df0f6c39ea4ab4631e8b5e5416080381386c3e44891fa1a75d4ebe4e0ad47db367247d6044938a78d0ed221b110
6
+ metadata.gz: b16a9d9f84f67aec9eaafc6a8751ff725d05e968b666c5337305b9b783b00db38fa587e916497613a9de8211ce1f2ec0121ea759ff61f2fee4b9f2601fd80d0f
7
+ data.tar.gz: 3ba348f58014dff70af4d00af675de5851325b1d3bca19329274cdb09ca9a5e4da23cd31765cc85d83811ea1397a366e5c8b05a4ac2cca42bd95303fecf2e68e
@@ -18,7 +18,8 @@ module LogStasher
18
18
  REQUEST_CONTEXT_KEY = :logstasher_request_context
19
19
 
20
20
  attr_accessor :logger, :logger_path, :enabled, :log_controller_parameters, :source, :backtrace,
21
- :controller_monkey_patch, :field_renaming
21
+ :controller_monkey_patch, :field_renaming
22
+
22
23
  # Setting the default to 'unknown' to define the default behaviour
23
24
  @source = 'unknown'
24
25
  # By default log the backtrace of exceptions
@@ -27,27 +28,27 @@ module LogStasher
27
28
  def remove_existing_log_subscriptions
28
29
  ::ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
29
30
  case subscriber.class.name
30
- when 'ActionView::LogSubscriber'
31
- unsubscribe(:action_view, subscriber)
32
- when 'ActionController::LogSubscriber'
33
- unsubscribe(:action_controller, subscriber)
34
- when 'ActionMailer::LogSubscriber'
35
- unsubscribe(:action_mailer, subscriber)
36
- when 'ActiveRecord::LogSubscriber'
37
- unsubscribe(:active_record, subscriber)
38
- when 'ActiveJob::Logging::LogSubscriber'
39
- unsubscribe(:active_job, subscriber)
31
+ when 'ActionView::LogSubscriber'
32
+ unsubscribe(:action_view, subscriber)
33
+ when 'ActionController::LogSubscriber'
34
+ unsubscribe(:action_controller, subscriber)
35
+ when 'ActionMailer::LogSubscriber'
36
+ unsubscribe(:action_mailer, subscriber)
37
+ when 'ActiveRecord::LogSubscriber'
38
+ unsubscribe(:active_record, subscriber)
39
+ when 'ActiveJob::LogSubscriber' # For Rails 6
40
+ unsubscribe(:active_job, subscriber)
41
+ when 'ActiveJob::Logging::LogSubscriber' # For Rails 5
42
+ unsubscribe(:active_job, subscriber)
40
43
  end
41
44
  end
42
45
  end
43
46
 
44
47
  def unsubscribe(component, subscriber)
45
- events = subscriber.public_methods(false).reject{ |method| method.to_s == 'call' }
48
+ events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' }
46
49
  events.each do |event|
47
50
  ::ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener|
48
- if listener.instance_variable_get('@delegate') == subscriber
49
- ::ActiveSupport::Notifications.unsubscribe listener
50
- end
51
+ ::ActiveSupport::Notifications.unsubscribe listener if listener.instance_variable_get('@delegate') == subscriber
51
52
  end
52
53
  end
53
54
  end
@@ -57,14 +58,14 @@ module LogStasher
57
58
  payload[:route] = "#{request.params[:controller]}##{request.params[:action]}"
58
59
  payload[:request_id] = request.env['action_dispatch.request_id']
59
60
  LogStasher::CustomFields.add(:ip, :route, :request_id)
60
- if self.log_controller_parameters
61
+ if log_controller_parameters
61
62
  payload[:parameters] = payload[:params].except(*::ActionController::LogSubscriber::INTERNAL_PARAMS)
62
63
  LogStasher::CustomFields.add(:parameters)
63
64
  end
64
65
  end
65
66
 
66
67
  def add_custom_fields(&block)
67
- wrapped_block = Proc.new do |fields|
68
+ wrapped_block = proc do |fields|
68
69
  LogStasher::CustomFields.add(*LogStasher.store.keys)
69
70
  instance_exec(fields, &block)
70
71
  end
@@ -73,7 +74,7 @@ module LogStasher
73
74
  end
74
75
 
75
76
  def add_custom_fields_to_request_context(&block)
76
- wrapped_block = Proc.new do |fields|
77
+ wrapped_block = proc do |fields|
77
78
  instance_exec(fields, &block)
78
79
  LogStasher::CustomFields.add(*fields.keys)
79
80
  end
@@ -90,7 +91,6 @@ module LogStasher
90
91
  end
91
92
 
92
93
  def setup_before(config)
93
- require 'logstash-event'
94
94
  self.enabled = config.enabled
95
95
  LogStasher::ActiveSupport::LogSubscriber.attach_to :action_controller if config.controller_enabled
96
96
  LogStasher::ActiveSupport::MailerLogSubscriber.attach_to :action_mailer if config.mailer_enabled
@@ -101,27 +101,27 @@ module LogStasher
101
101
 
102
102
  def setup(config)
103
103
  # Path instrumentation class to insert our hook
104
- if (! config.controller_monkey_patch && config.controller_monkey_patch != false) || config.controller_monkey_patch == true
104
+ if (!config.controller_monkey_patch && config.controller_monkey_patch != false) || config.controller_monkey_patch == true
105
105
  require 'logstasher/rails_ext/action_controller/metal/instrumentation'
106
106
  end
107
- self.suppress_app_logs(config)
107
+ suppress_app_logs(config)
108
108
  self.logger_path = config.logger_path || "#{Rails.root}/log/logstash_#{Rails.env}.log"
109
- self.logger = config.logger || new_logger(self.logger_path)
110
- self.logger.level = config.log_level || Logger::WARN
109
+ self.logger = config.logger || new_logger(logger_path)
110
+ logger.level = config.log_level || Logger::WARN
111
111
  self.source = config.source unless config.source.nil?
112
- self.log_controller_parameters = !! config.log_controller_parameters
113
- self.backtrace = !! config.backtrace unless config.backtrace.nil?
114
- self.set_data_for_rake
115
- self.set_data_for_console
112
+ self.log_controller_parameters = !!config.log_controller_parameters
113
+ self.backtrace = !!config.backtrace unless config.backtrace.nil?
114
+ set_data_for_rake
115
+ set_data_for_console
116
116
  self.field_renaming = Hash(config.field_renaming)
117
117
  end
118
118
 
119
119
  def set_data_for_rake
120
- self.request_context['request_id'] = ::Rake.application.top_level_tasks if self.called_as_rake?
120
+ request_context['request_id'] = ::Rake.application.top_level_tasks if called_as_rake?
121
121
  end
122
122
 
123
123
  def set_data_for_console
124
- self.request_context['request_id'] = "#{Process.pid}" if self.called_as_console?
124
+ request_context['request_id'] = Process.pid.to_s if called_as_console?
125
125
  end
126
126
 
127
127
  def called_as_rake?
@@ -159,10 +159,10 @@ module LogStasher
159
159
  # LogStasher.info("message", tags:["tag1", "tag2"])
160
160
  # LogStasher.info("message", timing:1234)
161
161
  # LogStasher.info(custom1:"yes", custom2:"no")
162
- def log(severity, message, additional_fields={})
163
- if self.logger && self.logger.send("#{severity}?")
162
+ def log(severity, message, additional_fields = {})
163
+ if logger && logger.send("#{severity}?")
164
164
 
165
- data = {'level' => severity}
165
+ data = { 'level' => severity }
166
166
  if message.respond_to?(:to_hash)
167
167
  data.merge!(message.to_hash)
168
168
  else
@@ -173,16 +173,16 @@ module LogStasher
173
173
  tags = Array(additional_fields.delete(:tags) || 'log')
174
174
 
175
175
  data.merge!(additional_fields)
176
- self.logger << build_logstash_event(data, tags).to_json + "\n"
176
+ logger << build_logstash_event(data, tags).to_json + "\n"
177
177
 
178
178
  end
179
179
  end
180
180
 
181
181
  def build_logstash_event(data, tags)
182
182
  field_renaming.each do |old_name, new_name|
183
- data[new_name] = data.delete(old_name) if data.key?(old_name)
183
+ data[new_name] = data.delete(old_name) if data.key?(old_name)
184
184
  end
185
- Event.new(data.merge('source' => self.source, 'tags' => tags))
185
+ Event.new(data.merge('source' => source, 'tags' => tags))
186
186
  end
187
187
 
188
188
  def store
@@ -205,7 +205,7 @@ module LogStasher
205
205
  end
206
206
  end
207
207
 
208
- %w( fatal error warn info debug unknown ).each do |severity|
208
+ %w[fatal error warn info debug unknown].each do |severity|
209
209
  eval <<-EOM, nil, __FILE__, __LINE__ + 1
210
210
  def #{severity}(message=nil, additional_fields={})
211
211
  self.log(:#{severity}, message, additional_fields)
@@ -214,7 +214,7 @@ module LogStasher
214
214
  end
215
215
 
216
216
  def enabled?
217
- self.enabled || false
217
+ enabled || false
218
218
  end
219
219
 
220
220
  private
@@ -10,8 +10,8 @@ module LogStasher
10
10
  def render_template(event)
11
11
  logstash_event(event)
12
12
  end
13
- alias :render_partial :render_template
14
- alias :render_collection :render_template
13
+ alias render_partial render_template
14
+ alias render_collection render_template
15
15
 
16
16
  def logger
17
17
  LogStasher.logger
@@ -35,7 +35,7 @@ module LogStasher
35
35
  end
36
36
 
37
37
  def extract_data(data)
38
- { identifier: from_rails_root(data[:identifier]) }
38
+ { identifier: from_rails_root(data[:identifier]) }
39
39
  end
40
40
 
41
41
  def request_context
@@ -49,16 +49,15 @@ module LogStasher
49
49
  def event_data(event)
50
50
  {
51
51
  name: event.name,
52
- transaction_id: event.transaction_id,
52
+ transaction_id: event.transaction_id
53
53
  }
54
54
  end
55
55
 
56
56
  def runtimes(event)
57
57
  {
58
- duration: event.duration,
59
- }.inject({}) do |runtimes, (name, runtime)|
58
+ duration: event.duration
59
+ }.each_with_object({}) do |(name, runtime), runtimes|
60
60
  runtimes[name] = runtime.to_f.round(2) if runtime
61
- runtimes
62
61
  end
63
62
  end
64
63
  end
@@ -1,13 +1,20 @@
1
- begin
2
- # `rescue nil` didn't work for some Ruby versions
3
- require 'active_job/logging'
4
- rescue LoadError
1
+ # For Rails 6.0 or below, require the logging module which contains LogSubscriber
2
+ if ActiveJob::VERSION::MAJOR < 6 || (ActiveJob::VERSION::MAJOR == 6 && ActiveJob::VERSION::MINOR == 0)
3
+ require 'active_job/logging'
4
+ else
5
+ require 'active_job/log_subscriber'
5
6
  end
6
7
 
7
8
  module LogStasher
8
9
  module ActiveJob
9
- class LogSubscriber < ::ActiveJob::Logging::LogSubscriber
10
10
 
11
+ BASE_SUBSCRIBER = if defined?(::ActiveJob::LogSubscriber)
12
+ ::ActiveJob::LogSubscriber
13
+ else
14
+ ::ActiveJob::Logging::LogSubscriber
15
+ end
16
+
17
+ class LogSubscriber < BASE_SUBSCRIBER
11
18
  def enqueue(event)
12
19
  process_event(event, 'enqueue')
13
20
  end
@@ -59,15 +66,15 @@ module LogStasher
59
66
 
60
67
  def extract_metadata(event)
61
68
  {
62
- :job_id => event.payload[:job].job_id,
63
- :queue_name => queue_name(event),
64
- :job_class => event.payload[:job].class.to_s,
65
- :job_args => args_info(event.payload[:job]),
69
+ job_id: event.payload[:job].job_id,
70
+ queue_name: queue_name(event),
71
+ job_class: event.payload[:job].class.to_s,
72
+ job_args: args_info(event.payload[:job])
66
73
  }
67
74
  end
68
75
 
69
76
  def extract_duration(event)
70
- { :duration => event.duration.to_f.round(2) }
77
+ { duration: event.duration.to_f.round(2) }
71
78
  end
72
79
 
73
80
  def extract_exception(event)
@@ -75,7 +82,7 @@ module LogStasher
75
82
  end
76
83
 
77
84
  def extract_scheduled_at(event)
78
- { :scheduled_at => scheduled_at(event) }
85
+ { scheduled_at: scheduled_at(event) }
79
86
  end
80
87
 
81
88
  def request_context
@@ -86,7 +93,7 @@ module LogStasher
86
93
  def args_info(job)
87
94
  job.arguments.map { |arg| arg.try(:to_global_id).try(:to_s) || arg }
88
95
  end
89
-
90
96
  end
91
97
  end
92
- end if defined?(::ActiveJob::Logging::LogSubscriber)
98
+ end
99
+
@@ -9,11 +9,9 @@ module LogStasher
9
9
 
10
10
  def identity(event)
11
11
  lsevent = logstash_event(event)
12
- if logger && lsevent
13
- logger << lsevent.to_json + "\n"
14
- end
12
+ logger << lsevent.to_json + "\n" if logger && lsevent
15
13
  end
16
- alias :sql :identity
14
+ alias sql identity
17
15
 
18
16
  def logger
19
17
  LogStasher.logger
@@ -22,17 +20,22 @@ module LogStasher
22
20
  private
23
21
 
24
22
  def logstash_event(event)
25
- data = event.payload
23
+ self.class.runtime += event.duration
24
+ data = event.payload.dup
26
25
 
27
26
  return if 'SCHEMA' == data[:name]
28
27
 
28
+ # A connection cannot be converted to JSON as it fails with
29
+ # SystemStackError when running against ActiveSupport JSON patches.
30
+ data.delete(:connection)
31
+
29
32
  data.merge! runtimes(event)
30
33
  data.merge! extract_sql(data)
31
34
  data.merge! request_context
32
35
  data.merge! LogStasher.store
33
36
  data.merge! extract_custom_fields(data)
34
37
 
35
- tags = [ 'request' ]
38
+ tags = ['request']
36
39
  tags.push('exception') if data[:exception]
37
40
  LogStasher.build_logstash_event(data, tags)
38
41
  end
@@ -45,7 +48,7 @@ module LogStasher
45
48
  if event.duration
46
49
  { duration: event.duration.to_f.round(2) }
47
50
  else
48
- { }
51
+ {}
49
52
  end
50
53
  end
51
54
 
@@ -44,7 +44,7 @@ module LogStasher
44
44
  end
45
45
 
46
46
  def extract_path(payload)
47
- payload[:path].split("?").first
47
+ payload[:path].split('?').first
48
48
  end
49
49
 
50
50
  def extract_format(payload)
@@ -57,27 +57,26 @@ module LogStasher
57
57
 
58
58
  def extract_status(payload)
59
59
  if payload[:status]
60
- { :status => payload[:status].to_i }
60
+ { status: payload[:status].to_i }
61
61
  else
62
- { :status => 0 }
62
+ { status: 0 }
63
63
  end
64
64
  end
65
65
 
66
66
  def runtimes(event)
67
67
  {
68
- :duration => event.duration,
69
- :view => event.payload[:view_runtime],
70
- :db => event.payload[:db_runtime]
71
- }.inject({}) do |runtimes, (name, runtime)|
68
+ duration: event.duration,
69
+ view: event.payload[:view_runtime],
70
+ db: event.payload[:db_runtime]
71
+ }.each_with_object({}) do |(name, runtime), runtimes|
72
72
  runtimes[name] = runtime.to_f.round(2) if runtime
73
- runtimes
74
73
  end
75
74
  end
76
75
 
77
- def location(event)
76
+ def location(_event)
78
77
  if location = Thread.current[:logstasher_location]
79
78
  Thread.current[:logstasher_location] = nil
80
- { :location => location }
79
+ { location: location }
81
80
  else
82
81
  {}
83
82
  end
@@ -88,13 +87,13 @@ module LogStasher
88
87
  if payload[:exception]
89
88
  exception, message = payload[:exception]
90
89
  status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception)
91
- if LogStasher.backtrace
92
- backtrace = $!.backtrace.join("\n")
93
- else
94
- backtrace = $!.backtrace.first
95
- end
90
+ backtrace = if LogStasher.backtrace
91
+ $!.backtrace.join("\n")
92
+ else
93
+ $!.backtrace.first
94
+ end
96
95
  message = "#{exception}\n#{message}\n#{backtrace}"
97
- { :status => status, :error => message }
96
+ { status: status, error: message }
98
97
  else
99
98
  {}
100
99
  end
@@ -4,18 +4,23 @@ require 'active_support/log_subscriber'
4
4
  module LogStasher
5
5
  module ActiveSupport
6
6
  class MailerLogSubscriber < ::ActiveSupport::LogSubscriber
7
- MAILER_FIELDS = [:mailer, :action, :message_id, :from, :to]
7
+ MAILER_FIELDS = %i[mailer action message_id from to].freeze
8
8
 
9
9
  def deliver(event)
10
- process_event(event, ['mailer', 'deliver'])
10
+ process_event(event, %w[mailer deliver])
11
11
  end
12
12
 
13
+ # This method will only be invoked on Rails 6.0 and prior.
14
+ # Starting in Rails 6.0 the receive method was deprecated in
15
+ # favor of ActionMailbox. The receive method was removed
16
+ # from ActionMailer in Rails 6.1, and there doesn't appear to
17
+ # be corresponding instrumentation for ActionMailbox.
13
18
  def receive(event)
14
- process_event(event, ['mailer', 'receive'])
19
+ process_event(event, %w[mailer receive])
15
20
  end
16
21
 
17
22
  def process(event)
18
- process_event(event, ['mailer', 'process'])
23
+ process_event(event, %w[mailer process])
19
24
  end
20
25
 
21
26
  def logger
@@ -5,7 +5,7 @@ module LogStasher
5
5
  (!CustomFields.custom_fields.empty? && data.extract!(*CustomFields.custom_fields)) || {}
6
6
  end
7
7
  end
8
-
8
+
9
9
  def self.clear
10
10
  Thread.current[:logstasher_custom_fields] = []
11
11
  end
@@ -3,7 +3,6 @@ require 'redis'
3
3
  module LogStasher
4
4
  module Device
5
5
  class Redis
6
-
7
6
  attr_reader :options, :redis
8
7
 
9
8
  def initialize(options = {})
@@ -23,7 +22,7 @@ module LogStasher
23
22
  def redis_options
24
23
  unless @redis_options
25
24
  default_keys = default_options.keys
26
- @redis_options = options.select { |k, v| !default_keys.include?(k) }
25
+ @redis_options = options.select { |k, _v| !default_keys.include?(k) }
27
26
  end
28
27
 
29
28
  @redis_options
@@ -36,7 +35,7 @@ module LogStasher
36
35
  when 'channel'
37
36
  redis.publish(key, log)
38
37
  else
39
- fail "Unknown data type #{data_type}"
38
+ raise "Unknown data type #{data_type}"
40
39
  end
41
40
  end
42
41
 
@@ -51,12 +50,12 @@ module LogStasher
51
50
  end
52
51
 
53
52
  def default_options
54
- { key: 'logstash', data_type: 'list' }
53
+ { key: 'logstash', data_type: 'list' }
55
54
  end
56
55
 
57
56
  def validate_options
58
- unless ['list', 'channel'].include?(options[:data_type])
59
- fail 'Expected :data_type to be either "list" or "channel"'
57
+ unless %w[list channel].include?(options[:data_type])
58
+ raise 'Expected :data_type to be either "list" or "channel"'
60
59
  end
61
60
  end
62
61
  end
@@ -1,31 +1,28 @@
1
- require "json"
2
- require "time"
3
- require "date"
1
+ require 'json'
2
+ require 'time'
3
+ require 'date'
4
4
 
5
5
  module LogStasher
6
6
  class Event
7
-
8
- def initialize(data={})
7
+ def initialize(data = {})
9
8
  @cancelled = false
10
9
 
11
10
  @data = data
12
- if data.include?("@timestamp")
13
- t = data["@timestamp"]
14
- if t.is_a?(String)
15
- data["@timestamp"] = Time.parse(t).gmtime
16
- end
11
+ if data.include?('@timestamp')
12
+ t = data['@timestamp']
13
+ data['@timestamp'] = Time.parse(t).gmtime.iso8601(3) if t.is_a?(String)
17
14
  else
18
- data["@timestamp"] = ::Time.now.utc
15
+ data['@timestamp'] = ::Time.now.utc.iso8601(3)
19
16
  end
20
- data["@version"] = "1" if !@data.include?("@version")
21
- end
17
+ data['@version'] = '1' unless @data.include?('@version')
18
+ end
22
19
 
23
20
  def to_s
24
21
  to_json.to_s
25
22
  end
26
-
23
+
27
24
  def to_json(*args)
28
- return @data.to_json(*args)
25
+ @data.to_json(*args)
29
26
  end
30
27
 
31
28
  def [](key)
@@ -9,17 +9,17 @@ module LogStasher
9
9
  super(*args)
10
10
  LogStasher::CustomFields.clear
11
11
  end
12
-
12
+
13
13
  private
14
14
 
15
15
  # this method is called from within super of process_action.
16
16
  def append_info_to_payload(payload) #:nodoc:
17
17
  LogStasher.add_default_fields_to_payload(payload, request)
18
- if self.respond_to?(:logstasher_add_custom_fields_to_request_context)
18
+ if respond_to?(:logstasher_add_custom_fields_to_request_context)
19
19
  logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
20
20
  end
21
21
 
22
- if self.respond_to?(:logstasher_add_custom_fields_to_payload)
22
+ if respond_to?(:logstasher_add_custom_fields_to_payload)
23
23
  before_keys = payload.keys.clone
24
24
  logstasher_add_custom_fields_to_payload(payload)
25
25
  after_keys = payload.keys
@@ -38,7 +38,7 @@ module LogStasher
38
38
  payload[key] = value
39
39
  end
40
40
  end
41
-
41
+
42
42
  def add_custom_fields_to_store
43
43
  LogStasher.store[:ip] = request.remote_ip
44
44
  LogStasher.store[:route] = "#{request.params[:controller]}##{request.params[:action]}"
@@ -1,14 +1,18 @@
1
1
  module ActionController
2
2
  module Instrumentation
3
- alias :orig_process_action :process_action
3
+ alias orig_process_action process_action
4
4
  def process_action(*args)
5
5
  raw_payload = {
6
- :controller => self.class.name,
7
- :action => self.action_name,
8
- :params => request.filtered_parameters,
9
- :format => request.format.try(:ref),
10
- :method => request.method,
11
- :path => (request.fullpath rescue "unknown")
6
+ controller: self.class.name,
7
+ action: action_name,
8
+ params: request.filtered_parameters,
9
+ format: request.format.try(:ref),
10
+ method: request.method,
11
+ path: begin
12
+ request.fullpath
13
+ rescue StandardError
14
+ 'unknown'
15
+ end
12
16
  }
13
17
 
14
18
  LogStasher.add_default_fields_to_payload(raw_payload, request)
@@ -16,14 +20,14 @@ module ActionController
16
20
  LogStasher.clear_request_context
17
21
  LogStasher.add_default_fields_to_request_context(request)
18
22
 
19
- ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
23
+ ActiveSupport::Notifications.instrument('start_processing.action_controller', raw_payload.dup)
20
24
 
21
- ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
22
- if self.respond_to?(:logstasher_add_custom_fields_to_request_context)
25
+ ActiveSupport::Notifications.instrument('process_action.action_controller', raw_payload) do |payload|
26
+ if respond_to?(:logstasher_add_custom_fields_to_request_context)
23
27
  logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
24
28
  end
25
29
 
26
- if self.respond_to?(:logstasher_add_custom_fields_to_payload)
30
+ if respond_to?(:logstasher_add_custom_fields_to_payload)
27
31
  before_keys = raw_payload.keys.clone
28
32
  logstasher_add_custom_fields_to_payload(raw_payload)
29
33
  after_keys = raw_payload.keys
@@ -45,6 +49,6 @@ module ActionController
45
49
  result
46
50
  end
47
51
  end
48
- alias :logstasher_process_action :process_action
52
+ alias logstasher_process_action process_action
49
53
  end
50
54
  end
@@ -17,8 +17,7 @@ module Rails
17
17
  end
18
18
 
19
19
  # Overwrites Rails 3.0/3.1 code that logs new requests
20
- def before_dispatch(env)
21
- end
20
+ def before_dispatch(env); end
22
21
  end
23
22
  end
24
23
  end
@@ -17,12 +17,12 @@ module LogStasher
17
17
 
18
18
  # Try loading the config/logstasher.yml if present
19
19
  env = Rails.env.to_sym || :development
20
- config_file = File.expand_path "./config/logstasher.yml"
20
+ config_file = File.expand_path './config/logstasher.yml'
21
21
 
22
22
  # Load and ERB templating of YAML files
23
- LOGSTASHER = File.exists?(config_file) ? YAML.load(ERB.new(File.read(config_file)).result).symbolize_keys : nil
23
+ LOGSTASHER = File.exist?(config_file) ? YAML.load(ERB.new(File.read(config_file)).result).symbolize_keys : nil
24
24
 
25
- initializer :logstasher, :before => :load_config_initializers do |app|
25
+ initializer :logstasher, before: :load_config_initializers do |app|
26
26
  if LOGSTASHER.present?
27
27
  # process common configs
28
28
  LogStasher.process_config(app.config.logstasher, LOGSTASHER)
@@ -79,6 +79,8 @@ module LogStasher
79
79
  config.backtrace = yml_config[:backtrace] if yml_config.key? :backtrace
80
80
  config.logger_path = yml_config[:logger_path] if yml_config.key? :logger_path
81
81
  config.log_level = yml_config[:log_level] if yml_config.key? :log_level
82
- config.log_controller_parameters = yml_config[:log_controller_parameters] if yml_config.key? :log_controller_parameters
82
+ if yml_config.key? :log_controller_parameters
83
+ config.log_controller_parameters = yml_config[:log_controller_parameters]
84
+ end
83
85
  end
84
86
  end
@@ -1,3 +1,3 @@
1
1
  module LogStasher
2
- VERSION = "1.4.0"
2
+ VERSION = '2.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shadab Ahmed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-27 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: logstash-event
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: request_store
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: activesupport
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '4.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '4.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '2.14'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '2.14'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: bundler
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +58,28 @@ dependencies:
86
58
  requirements:
87
59
  - - ">="
88
60
  - !ruby/object:Gem::Version
89
- version: '4.0'
61
+ version: '5.2'
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - ">="
95
67
  - !ruby/object:Gem::Version
96
- version: '4.0'
68
+ version: '5.2'
97
69
  - !ruby/object:Gem::Dependency
98
- name: activerecord
70
+ name: rspec
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - ">="
102
74
  - !ruby/object:Gem::Version
103
- version: '4.0'
75
+ version: '2.14'
104
76
  type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - ">="
109
81
  - !ruby/object:Gem::Version
110
- version: '4.0'
82
+ version: '2.14'
111
83
  description: Awesome rails logs
112
84
  email:
113
85
  - shadab.ansari@gmail.com
@@ -148,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
120
  - !ruby/object:Gem::Version
149
121
  version: '0'
150
122
  requirements: []
151
- rubygems_version: 3.0.3
123
+ rubygems_version: 3.2.3
152
124
  signing_key:
153
125
  specification_version: 4
154
126
  summary: Awesome rails logs