semantic_logger 4.2.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/Rakefile +1 -1
  4. data/lib/semantic_logger/ansi_colors.rb +11 -12
  5. data/lib/semantic_logger/appender.rb +4 -5
  6. data/lib/semantic_logger/appender/async.rb +24 -16
  7. data/lib/semantic_logger/appender/async_batch.rb +1 -4
  8. data/lib/semantic_logger/appender/bugsnag.rb +67 -63
  9. data/lib/semantic_logger/appender/elasticsearch.rb +154 -157
  10. data/lib/semantic_logger/appender/elasticsearch_http.rb +59 -55
  11. data/lib/semantic_logger/appender/file.rb +1 -3
  12. data/lib/semantic_logger/appender/graylog.rb +114 -110
  13. data/lib/semantic_logger/appender/honeybadger.rb +54 -51
  14. data/lib/semantic_logger/appender/http.rb +194 -190
  15. data/lib/semantic_logger/appender/kafka.rb +152 -149
  16. data/lib/semantic_logger/appender/mongodb.rb +3 -3
  17. data/lib/semantic_logger/appender/new_relic.rb +52 -49
  18. data/lib/semantic_logger/appender/sentry.rb +59 -54
  19. data/lib/semantic_logger/appender/splunk.rb +108 -103
  20. data/lib/semantic_logger/appender/splunk_http.rb +82 -79
  21. data/lib/semantic_logger/appender/syslog.rb +4 -5
  22. data/lib/semantic_logger/appender/tcp.rb +8 -29
  23. data/lib/semantic_logger/appender/udp.rb +2 -3
  24. data/lib/semantic_logger/appender/wrapper.rb +2 -2
  25. data/lib/semantic_logger/base.rb +18 -16
  26. data/lib/semantic_logger/concerns/compatibility.rb +0 -1
  27. data/lib/semantic_logger/core_ext/thread.rb +0 -1
  28. data/lib/semantic_logger/formatters.rb +3 -5
  29. data/lib/semantic_logger/formatters/base.rb +2 -3
  30. data/lib/semantic_logger/formatters/color.rb +29 -12
  31. data/lib/semantic_logger/formatters/default.rb +10 -10
  32. data/lib/semantic_logger/formatters/json.rb +0 -2
  33. data/lib/semantic_logger/formatters/one_line.rb +2 -2
  34. data/lib/semantic_logger/formatters/raw.rb +7 -10
  35. data/lib/semantic_logger/formatters/signalfx.rb +3 -5
  36. data/lib/semantic_logger/formatters/syslog.rb +2 -3
  37. data/lib/semantic_logger/formatters/syslog_cee.rb +2 -3
  38. data/lib/semantic_logger/jruby/garbage_collection_logger.rb +8 -5
  39. data/lib/semantic_logger/log.rb +17 -17
  40. data/lib/semantic_logger/loggable.rb +6 -9
  41. data/lib/semantic_logger/logger.rb +0 -1
  42. data/lib/semantic_logger/metric/new_relic.rb +58 -55
  43. data/lib/semantic_logger/metric/signalfx.rb +108 -106
  44. data/lib/semantic_logger/metric/statsd.rb +2 -3
  45. data/lib/semantic_logger/processor.rb +9 -9
  46. data/lib/semantic_logger/semantic_logger.rb +50 -30
  47. data/lib/semantic_logger/subscriber.rb +0 -1
  48. data/lib/semantic_logger/utils.rb +37 -37
  49. data/lib/semantic_logger/version.rb +2 -2
  50. data/test/appender/async_batch_test.rb +0 -1
  51. data/test/appender/async_test.rb +0 -1
  52. data/test/appender/bugsnag_test.rb +7 -8
  53. data/test/appender/elasticsearch_http_test.rb +5 -6
  54. data/test/appender/elasticsearch_test.rb +14 -10
  55. data/test/appender/file_test.rb +5 -6
  56. data/test/appender/graylog_test.rb +8 -8
  57. data/test/appender/honeybadger_test.rb +6 -7
  58. data/test/appender/http_test.rb +4 -5
  59. data/test/appender/kafka_test.rb +5 -6
  60. data/test/appender/mongodb_test.rb +11 -13
  61. data/test/appender/new_relic_test.rb +8 -9
  62. data/test/appender/newrelic_rpm.rb +1 -1
  63. data/test/appender/sentry_test.rb +7 -8
  64. data/test/appender/splunk_http_test.rb +4 -4
  65. data/test/appender/splunk_test.rb +1 -3
  66. data/test/appender/syslog_test.rb +3 -5
  67. data/test/appender/tcp_test.rb +4 -5
  68. data/test/appender/udp_test.rb +4 -5
  69. data/test/appender/wrapper_test.rb +2 -3
  70. data/test/concerns/compatibility_test.rb +0 -1
  71. data/test/debug_as_trace_logger_test.rb +0 -1
  72. data/test/formatters/color_test.rb +5 -6
  73. data/test/formatters/default_test.rb +16 -17
  74. data/test/formatters/one_line_test.rb +1 -2
  75. data/test/formatters/signalfx_test.rb +8 -11
  76. data/test/formatters_test.rb +3 -3
  77. data/test/in_memory_appender.rb +0 -1
  78. data/test/in_memory_appender_helper.rb +1 -1
  79. data/test/in_memory_batch_appender.rb +0 -1
  80. data/test/in_memory_metrics_appender.rb +0 -1
  81. data/test/loggable_test.rb +2 -3
  82. data/test/logger_test.rb +11 -14
  83. data/test/measure_test.rb +13 -15
  84. data/test/metric/new_relic_test.rb +2 -3
  85. data/test/metric/signalfx_test.rb +4 -5
  86. data/test/semantic_logger_test.rb +28 -3
  87. data/test/test_helper.rb +6 -7
  88. metadata +34 -34
@@ -20,18 +20,16 @@ module SemanticLogger
20
20
  # - Proc
21
21
  # - Any object that responds to :call
22
22
  def self.factory(formatter)
23
- case
24
- when formatter.is_a?(Symbol)
23
+ if formatter.is_a?(Symbol)
25
24
  SemanticLogger::Utils.constantize_symbol(formatter, 'SemanticLogger::Formatters').new
26
- when formatter.is_a?(Hash) && formatter.size > 0
25
+ elsif formatter.is_a?(Hash) && formatter.size.positive?
27
26
  fmt, options = formatter.first
28
27
  SemanticLogger::Utils.constantize_symbol(fmt.to_sym, 'SemanticLogger::Formatters').new(options)
29
- when formatter.respond_to?(:call)
28
+ elsif formatter.respond_to?(:call)
30
29
  formatter
31
30
  else
32
31
  raise(ArgumentError, "Unknown formatter: #{formatter.inspect}")
33
32
  end
34
33
  end
35
-
36
34
  end
37
35
  end
@@ -8,7 +8,7 @@ module SemanticLogger
8
8
  # JRuby 9.1.8.0 supports microseconds
9
9
  PRECISION =
10
10
  if defined?(JRuby)
11
- if (JRUBY_VERSION.to_f >= 9.1)
11
+ if JRUBY_VERSION.to_f >= 9.1
12
12
  maint = JRUBY_VERSION.match(/\A\d+\.\d+\.(\d+)\./)[1].to_i
13
13
  (maint >= 8) || (JRUBY_VERSION.to_f > 9.1) ? 6 : 3
14
14
  else
@@ -17,7 +17,7 @@ module SemanticLogger
17
17
  else
18
18
  6
19
19
  end
20
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S.%#{PRECISION}N"
20
+ TIME_FORMAT = "%Y-%m-%d %H:%M:%S.%#{PRECISION}N".freeze
21
21
 
22
22
  # Parameters
23
23
  # time_format: [String|Symbol|nil]
@@ -56,7 +56,6 @@ module SemanticLogger
56
56
  time.strftime(time_format)
57
57
  end
58
58
  end
59
-
60
59
  end
61
60
  end
62
61
  end
@@ -2,6 +2,7 @@
2
2
  begin
3
3
  require 'awesome_print'
4
4
  rescue LoadError
5
+ nil
5
6
  end
6
7
 
7
8
  module SemanticLogger
@@ -13,7 +14,14 @@ module SemanticLogger
13
14
  class ColorMap
14
15
  attr_accessor :trace, :debug, :info, :warn, :error, :fatal, :bold, :clear
15
16
 
16
- def initialize(trace: AnsiColors::MAGENTA, debug: AnsiColors::GREEN, info: AnsiColors::CYAN, warn: AnsiColors::BOLD, error: AnsiColors::RED, fatal: AnsiColors::RED, bold: AnsiColors::BOLD, clear: AnsiColors::CLEAR)
17
+ def initialize(trace: AnsiColors::MAGENTA,
18
+ debug: AnsiColors::GREEN,
19
+ info: AnsiColors::CYAN,
20
+ warn: AnsiColors::BOLD,
21
+ error: AnsiColors::RED,
22
+ fatal: AnsiColors::RED,
23
+ bold: AnsiColors::BOLD,
24
+ clear: AnsiColors::CLEAR)
17
25
  @trace = trace
18
26
  @debug = debug
19
27
  @info = info
@@ -50,7 +58,11 @@ module SemanticLogger
50
58
  #
51
59
  # color_map: [Hash | SemanticLogger::Formatters::Color::ColorMap]
52
60
  # ColorMaps each of the log levels to a color
53
- def initialize(ap: {multiline: false}, color_map: ColorMap.new, time_format: TIME_FORMAT, log_host: false, log_application: false)
61
+ def initialize(ap: {multiline: false},
62
+ color_map: ColorMap.new,
63
+ time_format: TIME_FORMAT,
64
+ log_host: false,
65
+ log_application: false)
54
66
  @ai_options = ap
55
67
  @color_map = color_map.is_a?(ColorMap) ? color_map : ColorMap.new(color_map)
56
68
  super(time_format: time_format, log_host: log_host, log_application: log_application)
@@ -66,11 +78,12 @@ module SemanticLogger
66
78
 
67
79
  # Named Tags
68
80
  def named_tags
69
- if (named_tags = log.named_tags) && !named_tags.empty?
70
- list = []
71
- named_tags.each_pair { |name, value| list << "#{color}#{name}: #{value}#{color_map.clear}" }
72
- "{#{list.join(', ')}}"
73
- end
81
+ named_tags = log.named_tags
82
+ return if named_tags.nil? || named_tags.empty?
83
+
84
+ list = []
85
+ named_tags.each_pair { |name, value| list << "#{color}#{name}: #{value}#{color_map.clear}" }
86
+ "{#{list.join(', ')}}"
74
87
  end
75
88
 
76
89
  def duration
@@ -82,25 +95,29 @@ module SemanticLogger
82
95
  end
83
96
 
84
97
  def payload
85
- return unless log.has_payload?
98
+ return unless log.payload?
86
99
 
87
100
  if !defined?(AwesomePrint) || !log.payload.respond_to?(:ai)
88
101
  super
89
102
  else
90
- "-- #{log.payload.ai(@ai_options)}" rescue super
103
+ begin
104
+ "-- #{log.payload.ai(@ai_options)}"
105
+ rescue StandardError
106
+ super
107
+ end
91
108
  end
92
109
  end
93
110
 
94
111
  def exception
95
- "-- Exception: #{color}#{log.exception.class}: #{log.exception.message}#{color_map.clear}\n#{log.backtrace_to_s}" if log.exception
112
+ return unless log.exception
113
+
114
+ "-- Exception: #{color}#{log.exception.class}: #{log.exception.message}#{color_map.clear}\n#{log.backtrace_to_s}"
96
115
  end
97
116
 
98
117
  def call(log, logger)
99
118
  self.color = color_map[log.level]
100
119
  super(log, logger)
101
120
  end
102
-
103
121
  end
104
122
  end
105
123
  end
106
-
@@ -24,11 +24,12 @@ module SemanticLogger
24
24
 
25
25
  # Named Tags
26
26
  def named_tags
27
- if (named_tags = log.named_tags) && !named_tags.empty?
28
- list = []
29
- named_tags.each_pair { |name, value| list << "#{name}: #{value}" }
30
- "{#{list.join(', ')}}"
31
- end
27
+ named_tags = log.named_tags
28
+ return if named_tags.nil? || named_tags.empty?
29
+
30
+ list = []
31
+ named_tags.each_pair { |name, value| list << "#{name}: #{value}" }
32
+ "{#{list.join(', ')}}"
32
33
  end
33
34
 
34
35
  # Duration
@@ -48,9 +49,10 @@ module SemanticLogger
48
49
 
49
50
  # Payload
50
51
  def payload
51
- if pl = log.payload_to_s
52
- "-- #{pl}"
53
- end
52
+ pl = log.payload_to_s
53
+ return unless pl
54
+
55
+ "-- #{pl}"
54
56
  end
55
57
 
56
58
  # Exception
@@ -67,8 +69,6 @@ module SemanticLogger
67
69
 
68
70
  [time, level, process_info, tags, named_tags, duration, name, message, payload, exception].compact.join(' ')
69
71
  end
70
-
71
72
  end
72
73
  end
73
74
  end
74
-
@@ -11,8 +11,6 @@ module SemanticLogger
11
11
  def call(log, logger)
12
12
  super(log, logger).to_json
13
13
  end
14
-
15
14
  end
16
15
  end
17
16
  end
18
-
@@ -7,11 +7,11 @@ module SemanticLogger
7
7
  # * Exceptions only include the class and message, the stack trace is not shown.
8
8
  class OneLine < Default
9
9
  def message
10
- "-- #{log.message.gsub("\n", '')}" if log.message
10
+ "-- #{log.message.delete("\n")}" if log.message
11
11
  end
12
12
 
13
13
  def exception
14
- "-- Exception: #{log.exception.class}: #{log.exception.message.gsub("\n", '')}" if log.exception
14
+ "-- Exception: #{log.exception.class}: #{log.exception.message.delete("\n")}" if log.exception
15
15
  end
16
16
  end
17
17
  end
@@ -2,7 +2,6 @@ require 'json'
2
2
  module SemanticLogger
3
3
  module Formatters
4
4
  class Raw < Base
5
-
6
5
  # Fields are added by populating this hash.
7
6
  attr_accessor :hash, :log, :logger, :time_key
8
7
 
@@ -35,14 +34,14 @@ module SemanticLogger
35
34
 
36
35
  # Process info
37
36
  def process_info
38
- hash[:pid] = $$
37
+ hash[:pid] = $PROCESS_ID
39
38
  hash[:thread] = log.thread_name
40
39
 
41
40
  file, line = log.file_name_and_line
42
- if file
43
- hash[:file] = file
44
- hash[:line] = line.to_i
45
- end
41
+ return unless file
42
+
43
+ hash[:file] = file
44
+ hash[:line] = line.to_i
46
45
  end
47
46
 
48
47
  # Tags
@@ -75,7 +74,7 @@ module SemanticLogger
75
74
 
76
75
  # Payload
77
76
  def payload
78
- hash[:payload] = log.payload if log.payload && log.payload.respond_to?(:empty?) && !log.payload.empty?
77
+ hash[:payload] = log.payload if log.payload&.respond_to?(:empty?) && !log.payload.empty?
79
78
  end
80
79
 
81
80
  # Exception
@@ -83,7 +82,7 @@ module SemanticLogger
83
82
  return unless log.exception
84
83
  root = hash
85
84
  log.each_exception do |exception, i|
86
- name = i == 0 ? :exception : :cause
85
+ name = i.zero? ? :exception : :cause
87
86
  root[name] = {
88
87
  name: exception.class.name,
89
88
  message: exception.message,
@@ -108,8 +107,6 @@ module SemanticLogger
108
107
  host; application; time; level; process_info; duration; tags; named_tags; name; message; payload; exception; metric
109
108
  hash
110
109
  end
111
-
112
110
  end
113
111
  end
114
112
  end
115
-
@@ -30,13 +30,12 @@ module SemanticLogger
30
30
  # Strip leading '/'
31
31
  # Convert remaining '/' to '.'
32
32
  def metric
33
+ name = log.metric.to_s.sub(/\A\/+/, '')
33
34
  if log.dimensions
34
- name = log.metric.to_s.sub(/\A\/+/, '')
35
- name.gsub!('/', '.')
35
+ name.tr!('/', '.')
36
36
  hash[:metric] = name
37
37
  else
38
38
  # Extract class and action from metric name
39
- name = log.metric.to_s.sub(/\A\/+/, '')
40
39
  names = name.split('/')
41
40
  h = (hash[:dimensions] ||= {})
42
41
  if names.size > 1
@@ -75,7 +74,7 @@ module SemanticLogger
75
74
  name = name.to_sym
76
75
  value = value.to_s
77
76
  next if value.empty?
78
- h[name] = value if dimensions && dimensions.include?(name)
77
+ h[name] = value if dimensions&.include?(name)
79
78
  end
80
79
  end
81
80
  h[:host] = logger.host if log_host && logger.host
@@ -163,7 +162,6 @@ module SemanticLogger
163
162
  (item[:dimensions] == metric[:dimensions])
164
163
  end
165
164
  end
166
-
167
165
  end
168
166
  end
169
167
  end
@@ -1,7 +1,7 @@
1
1
  begin
2
2
  require 'syslog_protocol'
3
3
  rescue LoadError
4
- raise 'Gem syslog_protocol is required for remote logging using the Syslog protol. Please add the gem "syslog_protocol" to your Gemfile.'
4
+ raise 'Gem syslog_protocol is required for remote logging using the Syslog protocol. Please add the gem "syslog_protocol" to your Gemfile.'
5
5
  end
6
6
 
7
7
  module SemanticLogger
@@ -73,7 +73,7 @@ module SemanticLogger
73
73
  packet = SyslogProtocol::Packet.new
74
74
  packet.hostname = logger.host
75
75
  packet.facility = facility
76
- packet.tag = logger.application.gsub(' ', '')
76
+ packet.tag = logger.application.delete(' ')
77
77
  packet.content = message
78
78
  packet.time = log.time
79
79
  packet.severity = level_map[log.level]
@@ -82,4 +82,3 @@ module SemanticLogger
82
82
  end
83
83
  end
84
84
  end
85
-
@@ -1,7 +1,7 @@
1
1
  begin
2
2
  require 'syslog_protocol'
3
3
  rescue LoadError
4
- raise 'Gem syslog_protocol is required for remote logging using the Syslog protol. Please add the gem "syslog_protocol" to your Gemfile.'
4
+ raise 'Gem syslog_protocol is required for remote logging using the Syslog protocol. Please add the gem "syslog_protocol" to your Gemfile.'
5
5
  end
6
6
 
7
7
  module SemanticLogger
@@ -45,7 +45,7 @@ module SemanticLogger
45
45
  packet = SyslogProtocol::Packet.new
46
46
  packet.hostname = logger.host
47
47
  packet.facility = facility
48
- packet.tag = logger.application.gsub(' ', '')
48
+ packet.tag = logger.application.delete(' ')
49
49
  packet.content = message
50
50
  packet.time = log.time
51
51
  packet.severity = level_map[log.level]
@@ -54,4 +54,3 @@ module SemanticLogger
54
54
  end
55
55
  end
56
56
  end
57
-
@@ -5,7 +5,7 @@ module SemanticLogger
5
5
 
6
6
  # Only log the garbage collection if the number of microseconds exceeds
7
7
  # this value
8
- def initialize(min_microseconds = 10000)
8
+ def initialize(min_microseconds = 10_000)
9
9
  @min_microseconds = min_microseconds
10
10
  end
11
11
 
@@ -17,11 +17,14 @@ module SemanticLogger
17
17
  info = Java::ComSunManagement::GarbageCollectionNotificationInfo.from(notification.user_data)
18
18
  gc_info = info.gc_info
19
19
  duration = gc_info.duration
20
- if duration >= @min_microseconds
21
- SemanticLogger['GarbageCollector'].measure_warn "Garbage Collection completed: #{info.gc_name} ##{gc_info.id}", duration: duration.to_f / 1000
22
- end
20
+
21
+ return unless duration >= @min_microseconds
22
+
23
+ SemanticLogger['GarbageCollector'].measure_warn(
24
+ "Garbage Collection completed: #{info.gc_name} ##{gc_info.id}",
25
+ duration: duration.to_f / 1000
26
+ )
23
27
  end
24
28
  end
25
-
26
29
  end
27
30
  end
@@ -97,6 +97,7 @@ module SemanticLogger
97
97
  self.message = "#{message} -- Exception: #{exception.class}: #{exception.message}"
98
98
  when nil, :none
99
99
  # Log the message without the exception that was raised
100
+ nil
100
101
  else
101
102
  raise(ArgumentError, "Invalid value:#{log_exception.inspect} for argument :log_exception")
102
103
  end
@@ -119,7 +120,7 @@ module SemanticLogger
119
120
  self.dimensions = dimensions
120
121
  end
121
122
 
122
- self.payload = payload if payload && (payload.size > 0)
123
+ self.payload = payload if payload&.size&.positive?
123
124
  true
124
125
  end
125
126
 
@@ -150,7 +151,7 @@ module SemanticLogger
150
151
  assign(message: message, payload: payload, exception: exception)
151
152
  elsif message.nil? && result.is_a?(Hash)
152
153
  assign(result)
153
- elsif payload && payload.respond_to?(:merge)
154
+ elsif payload&.respond_to?(:merge)
154
155
  assign(message: message, payload: payload.merge(result), exception: exception)
155
156
  else
156
157
  assign(message: message, payload: result, exception: exception)
@@ -167,7 +168,7 @@ module SemanticLogger
167
168
  depth = 0
168
169
  exceptions = []
169
170
  ex = exception
170
- while ex != nil && !exceptions.include?(ex) && exceptions.length < MAX_EXCEPTIONS_TO_UNWRAP
171
+ while !ex.nil? && !exceptions.include?(ex) && exceptions.length < MAX_EXCEPTIONS_TO_UNWRAP
171
172
  exceptions << ex
172
173
  yield(ex, depth)
173
174
 
@@ -187,7 +188,7 @@ module SemanticLogger
187
188
  def backtrace_to_s
188
189
  trace = ''
189
190
  each_exception do |exception, i|
190
- if i == 0
191
+ if i.zero?
191
192
  trace = (exception.backtrace || []).join("\n")
192
193
  else
193
194
  trace << "\nCause: #{exception.class.name}: #{exception.message}\n#{(exception.backtrace || []).join("\n")}"
@@ -206,7 +207,7 @@ module SemanticLogger
206
207
  else
207
208
  def duration_to_s
208
209
  return unless duration
209
- duration < 10.0 ? "#{'%.3f' % duration}ms" : "#{'%.1f' % duration}ms"
210
+ duration < 10.0 ? "#{format('%.3f', duration)}ms" : "#{format('%.1f', duration)}ms"
210
211
  end
211
212
  end
212
213
 
@@ -214,14 +215,14 @@ module SemanticLogger
214
215
  def duration_human
215
216
  return nil unless duration
216
217
  seconds = duration / 1000
217
- if seconds >= 86400.0 # 1 day
218
- "#{(seconds / 86400).to_i}d #{Time.at(seconds).strftime('%-Hh %-Mm')}"
218
+ if seconds >= 86_400.0 # 1 day
219
+ "#{(seconds / 86_400).to_i}d #{Time.at(seconds).strftime('%-Hh %-Mm')}"
219
220
  elsif seconds >= 3600.0 # 1 hour
220
221
  Time.at(seconds).strftime('%-Hh %-Mm')
221
222
  elsif seconds >= 60.0 # 1 minute
222
223
  Time.at(seconds).strftime('%-Mm %-Ss')
223
224
  elsif seconds >= 1.0 # 1 second
224
- "#{'%.3f' % seconds}s"
225
+ "#{format('%.3f', seconds)}s"
225
226
  else
226
227
  duration_to_s
227
228
  end
@@ -239,7 +240,7 @@ module SemanticLogger
239
240
  file, line = file_name_and_line(true)
240
241
  file_name = " #{file}:#{line}" if file
241
242
 
242
- "#{$$}:#{"%.#{thread_name_length}s" % thread_name}#{file_name}"
243
+ "#{$PROCESS_ID}:#{format("%.#{thread_name_length}s", thread_name)}#{file_name}"
243
244
  end
244
245
 
245
246
  CALLER_REGEXP = /^(.*):(\d+).*/
@@ -253,10 +254,8 @@ module SemanticLogger
253
254
  # Returns [String, String] the file_name and line_number from the backtrace supplied
254
255
  # in either the backtrace or exception
255
256
  def file_name_and_line(short_name = false)
256
- if backtrace || (exception && exception.backtrace)
257
- stack = backtrace || exception.backtrace
258
- extract_file_and_line(stack, short_name) if stack && stack.size > 0
259
- end
257
+ stack = backtrace || exception&.backtrace
258
+ extract_file_and_line(stack, short_name) if stack&.size&.positive?
260
259
  end
261
260
 
262
261
  # Strip the standard Rails colorizing from the logged message
@@ -267,14 +266,17 @@ module SemanticLogger
267
266
  # Return the payload in text form
268
267
  # Returns nil if payload is missing or empty
269
268
  def payload_to_s
270
- payload.inspect if has_payload?
269
+ payload.inspect if payload?
271
270
  end
272
271
 
273
272
  # Returns [true|false] whether the log entry has a payload
274
- def has_payload?
273
+ def payload?
275
274
  !(payload.nil? || (payload.respond_to?(:empty?) && payload.empty?))
276
275
  end
277
276
 
277
+ # DEPRECATED
278
+ alias has_payload? payload?
279
+
278
280
  # DEPRECATED
279
281
  def formatted_time
280
282
  time.strftime(Formatters::Base::TIME_FORMAT)
@@ -297,7 +299,5 @@ module SemanticLogger
297
299
  def metric_only?
298
300
  metric && message.nil? && exception.nil? && payload.nil?
299
301
  end
300
-
301
302
  end
302
-
303
303
  end