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
@@ -9,11 +9,11 @@ module Appender
9
9
  @message = 'AppenderGraylogTest log message'
10
10
  end
11
11
 
12
- (SemanticLogger::LEVELS - [:info, :warn, :error, :fatal]).each do |level|
12
+ (SemanticLogger::LEVELS - %i[info warn error fatal]).each do |level|
13
13
  it "not send :#{level} notifications to Graylog" do
14
14
  hash = nil
15
- @appender.notifier.stub(:notify!, -> h { hash = h }) do
16
- @appender.send(level, "AppenderGraylogTest #{level.to_s} message")
15
+ @appender.notifier.stub(:notify!, ->(h) { hash = h }) do
16
+ @appender.send(level, "AppenderGraylogTest #{level} message")
17
17
  end
18
18
  assert_nil hash
19
19
  end
@@ -27,7 +27,7 @@ module Appender
27
27
  rescue Exception => e
28
28
  exc = e
29
29
  end
30
- @appender.notifier.stub(:notify!, -> h { hash = h }) do
30
+ @appender.notifier.stub(:notify!, ->(h) { hash = h }) do
31
31
  @appender.error 'Reading File', exc
32
32
  end
33
33
  assert_equal 'Reading File', hash[:short_message]
@@ -45,7 +45,7 @@ module Appender
45
45
  rescue Exception => e
46
46
  exc = e
47
47
  end
48
- @appender.notifier.stub(:notify!, -> h { hash = h }) do
48
+ @appender.notifier.stub(:notify!, ->(h) { hash = h }) do
49
49
  @appender.error exc
50
50
  end
51
51
  assert_equal exc.message, hash[:short_message]
@@ -57,7 +57,7 @@ module Appender
57
57
 
58
58
  it 'send error notifications to Graylog with severity' do
59
59
  hash = nil
60
- @appender.notifier.stub(:notify!, -> h { hash = h }) do
60
+ @appender.notifier.stub(:notify!, ->(h) { hash = h }) do
61
61
  @appender.error @message
62
62
  end
63
63
  assert_equal @message, hash[:short_message]
@@ -67,8 +67,8 @@ module Appender
67
67
 
68
68
  it 'send notification to Graylog with custom attributes' do
69
69
  hash = nil
70
- @appender.notifier.stub(:notify!, -> h { hash = h }) do
71
- @appender.error @message, {key1: 1, key2: 'a'}
70
+ @appender.notifier.stub(:notify!, ->(h) { hash = h }) do
71
+ @appender.error @message, key1: 1, key2: 'a'
72
72
  end
73
73
  assert_equal @message, hash[:short_message]
74
74
  assert_equal 3, hash[:level]
@@ -13,25 +13,25 @@ module Appender
13
13
  SemanticLogger::LEVELS.each do |level|
14
14
  it "sends #{level} message" do
15
15
  hash = nil
16
- Honeybadger.stub(:notify, -> h { hash = h }) do
16
+ Honeybadger.stub(:notify, ->(h) { hash = h }) do
17
17
  @appender.send(level, @message)
18
18
  end
19
19
  assert_equal @message, hash[:error_message]
20
20
  assert_equal 'SemanticLogger::Appender::Honeybadger', hash[:error_class]
21
21
 
22
- if [:error, :fatal].include?(level)
23
- assert hash.has_key?(:backtrace)
22
+ if %i[error fatal].include?(level)
23
+ assert hash.key?(:backtrace)
24
24
  else
25
- refute hash.has_key?(:backtrace)
25
+ refute hash.key?(:backtrace)
26
26
  end
27
- assert_equal true, hash.has_key?(:context)
27
+ assert_equal true, hash.key?(:context)
28
28
  assert_equal level, hash[:context][:level]
29
29
  end
30
30
 
31
31
  it "sends #{level} exceptions" do
32
32
  error = RuntimeError.new('Oh no, Error.')
33
33
  exception = hash = nil
34
- Honeybadger.stub(:notify, -> exc, h { exception = exc; hash = h }) do
34
+ Honeybadger.stub(:notify, ->(exc, h) { exception = exc; hash = h }) do
35
35
  @appender.send(level, @message, error)
36
36
  end
37
37
 
@@ -40,7 +40,6 @@ module Appender
40
40
  assert_equal @message, hash[:message], hash
41
41
  end
42
42
  end
43
-
44
43
  end
45
44
  end
46
45
  end
@@ -16,7 +16,7 @@ module Appender
16
16
  SemanticLogger::LEVELS.each do |level|
17
17
  it "send #{level}" do
18
18
  request = nil
19
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
19
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
20
20
  @appender.send(level, @message)
21
21
  end
22
22
  hash = JSON.parse(request.body)
@@ -33,7 +33,7 @@ module Appender
33
33
  exc = e
34
34
  end
35
35
  request = nil
36
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
36
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
37
37
  @appender.send(level, 'Reading File', exc)
38
38
  end
39
39
  hash = JSON.parse(request.body)
@@ -46,8 +46,8 @@ module Appender
46
46
 
47
47
  it "send #{level} custom attributes" do
48
48
  request = nil
49
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
50
- @appender.send(level, @message, {key1: 1, key2: 'a'})
49
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
50
+ @appender.send(level, @message, key1: 1, key2: 'a')
51
51
  end
52
52
  hash = JSON.parse(request.body)
53
53
  assert_equal @message, hash['message']
@@ -57,7 +57,6 @@ module Appender
57
57
  assert_equal 1, payload['key1'], payload
58
58
  assert_equal 'a', payload['key2'], payload
59
59
  end
60
-
61
60
  end
62
61
  end
63
62
  end
@@ -5,19 +5,19 @@ module Appender
5
5
  describe SemanticLogger::Appender::Kafka do
6
6
  before do
7
7
  @appender = SemanticLogger::Appender::Kafka.new(
8
- seed_brokers: ['http://localhost:9092']
8
+ seed_brokers: ['localhost:9092']
9
9
  )
10
10
  @message = 'AppenderKafkaTest log message'
11
11
  end
12
12
 
13
13
  after do
14
- @appender.close if @appender
14
+ @appender&.close
15
15
  end
16
16
 
17
17
  it 'sends log messages in JSON format' do
18
18
  message = nil
19
19
  options = nil
20
- ::Kafka::Producer.stub_any_instance(:produce, -> value, **opts { message = value; options = opts }) do
20
+ ::Kafka::Producer.stub_any_instance(:produce, ->(value, **opts) { message = value; options = opts }) do
21
21
  @appender.info(@message)
22
22
  @appender.flush
23
23
  end
@@ -25,12 +25,11 @@ module Appender
25
25
  h = JSON.parse(message)
26
26
  assert_equal 'info', h['level']
27
27
  assert_equal @message, h['message']
28
- assert_equal "SemanticLogger::Appender::Kafka", h['name']
29
- assert_equal $$, h['pid']
28
+ assert_equal 'SemanticLogger::Appender::Kafka', h['name']
29
+ assert_equal $PROCESS_ID, h['pid']
30
30
 
31
31
  assert_equal 'log_messages', options[:topic]
32
32
  end
33
-
34
33
  end
35
34
  end
36
35
  end
@@ -7,17 +7,17 @@ module Appender
7
7
  before do
8
8
  @appender = SemanticLogger::Appender::MongoDB.new(
9
9
  uri: 'mongodb://127.0.0.1:27017/test',
10
- collection_size: 10*1024**2, # 10MB
10
+ collection_size: 10 * 1024 ** 2, # 10MB
11
11
  host: 'test',
12
12
  application: 'test_application',
13
13
  level: :trace
14
14
  )
15
- @hash = {tracking_number: 12345, session_id: 'HSSKLEU@JDK767'}
15
+ @hash = {tracking_number: 12_345, session_id: 'HSSKLEU@JDK767'}
16
16
  Thread.current.name = 'thread'
17
17
  end
18
18
 
19
19
  after do
20
- @appender.purge_all if @appender
20
+ @appender&.purge_all
21
21
  end
22
22
 
23
23
  describe 'format logs into documents' do
@@ -29,7 +29,7 @@ module Appender
29
29
  assert_equal 'thread', document['thread']
30
30
  assert document['time'].is_a?(Time)
31
31
  assert_nil document['payload']
32
- assert_equal $$, document['pid']
32
+ assert_equal $PROCESS_ID, document['pid']
33
33
  assert_equal 'test', document['host']
34
34
  assert_equal 'test_application', document['application']
35
35
  end
@@ -43,9 +43,9 @@ module Appender
43
43
  assert_equal 'thread', document['thread']
44
44
  assert document['time'].is_a?(Time)
45
45
  assert payload = document['payload']
46
- assert_equal 12345, payload['tracking_number'], payload
46
+ assert_equal 12_345, payload['tracking_number'], payload
47
47
  assert_equal 'HSSKLEU@JDK767', payload['session_id']
48
- assert_equal $$, document['pid']
48
+ assert_equal $PROCESS_ID, document['pid']
49
49
  assert_equal 'test', document['host']
50
50
  assert_equal 'test_application', document['application']
51
51
  end
@@ -59,9 +59,9 @@ module Appender
59
59
  assert_equal 'thread', document['thread']
60
60
  assert document['time'].is_a?(Time)
61
61
  assert payload = document['payload']
62
- assert_equal 12345, payload['tracking_number'], payload
62
+ assert_equal 12_345, payload['tracking_number'], payload
63
63
  assert_equal 'HSSKLEU@JDK767', payload['session_id']
64
- assert_equal $$, document['pid']
64
+ assert_equal $PROCESS_ID, document['pid']
65
65
  assert_equal 'test', document['host']
66
66
  assert_equal 'test_application', document['application']
67
67
  end
@@ -74,7 +74,7 @@ module Appender
74
74
  assert_equal 'hello world', document['message']
75
75
  assert_equal 'thread', document['thread']
76
76
  assert document['time'].is_a?(Time)
77
- assert_equal $$, document['pid']
77
+ assert_equal $PROCESS_ID, document['pid']
78
78
  assert_equal 'test', document['host']
79
79
  assert_equal 'test_application', document['application']
80
80
  end
@@ -91,16 +91,14 @@ module Appender
91
91
  assert_equal 'thread', document['thread']
92
92
  assert document['time'].is_a?(Time)
93
93
  assert payload = document['payload']
94
- assert_equal 12345, payload['tracking_number'], payload
94
+ assert_equal 12_345, payload['tracking_number'], payload
95
95
  assert_equal 'HSSKLEU@JDK767', payload['session_id']
96
- assert_equal $$, document['pid']
96
+ assert_equal $PROCESS_ID, document['pid']
97
97
  assert_equal 'test', document['host'], document.ai
98
98
  assert_equal 'test_application', document['application']
99
99
  end
100
100
  end
101
-
102
101
  end
103
-
104
102
  end
105
103
  end
106
104
  end
@@ -6,18 +6,17 @@ require_relative '../test_helper'
6
6
  module Appender
7
7
  class NewRelicTest < Minitest::Test
8
8
  describe SemanticLogger::Appender::NewRelic do
9
-
10
9
  before do
11
10
  @appender = SemanticLogger::Appender::NewRelic.new
12
11
  @message = 'AppenderNewRelicTest log message'
13
12
  end
14
13
 
15
- (SemanticLogger::LEVELS - [:error, :fatal]).each do |level|
16
- it "does not send :#{level.to_s} notifications to New Relic" do
14
+ (SemanticLogger::LEVELS - %i[error fatal]).each do |level|
15
+ it "does not send :#{level} notifications to New Relic" do
17
16
  exception = hash = nil
18
- NewRelic::Agent.stub(:notice_error, -> exc, h { exception = exc; hash = h }) do
17
+ NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
19
18
  @appender.tagged('test') do
20
- @appender.send(level, "AppenderNewRelicTest #{level.to_s} message")
19
+ @appender.send(level, "AppenderNewRelicTest #{level} message")
21
20
  end
22
21
  end
23
22
  assert_nil exception
@@ -25,10 +24,10 @@ module Appender
25
24
  end
26
25
  end
27
26
 
28
- [:error, :fatal].each do |level|
29
- it "sends :#{level.to_s} notifications to New Relic" do
27
+ %i[error fatal].each do |level|
28
+ it "sends :#{level} notifications to New Relic" do
30
29
  exception = hash = nil
31
- NewRelic::Agent.stub(:notice_error, -> exc, h { exception = exc; hash = h }) do
30
+ NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
32
31
  @appender.tagged('test') do
33
32
  @appender.send(level, @message)
34
33
  end
@@ -43,7 +42,7 @@ module Appender
43
42
 
44
43
  it 'send notification to New Relic with custom attributes' do
45
44
  exception = hash = nil
46
- NewRelic::Agent.stub(:notice_error, -> exc, h { exception = exc; hash = h }) do
45
+ NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
47
46
  SemanticLogger.tagged('test') do
48
47
  SemanticLogger.named_tagged(key1: 1, key2: 'a') do
49
48
  @appender.measure_error(message: @message, payload: {key3: 4}) do
@@ -8,7 +8,7 @@ module NewRelic
8
8
  def self.record_metric(name, secoonds)
9
9
  end
10
10
 
11
- def self.increment_metric(name, count=1)
11
+ def self.increment_metric(name, count = 1)
12
12
  end
13
13
  end
14
14
  end
@@ -13,36 +13,35 @@ module Appender
13
13
  SemanticLogger::LEVELS.each do |level|
14
14
  it "sends #{level} message" do
15
15
  error_message = hash = nil
16
- Raven.stub(:capture_message, -> msg, h { error_message = msg; hash = h }) do
16
+ Raven.stub(:capture_message, ->(msg, h) { error_message = msg; hash = h }) do
17
17
  @appender.send(level, @message)
18
18
  end
19
19
  assert_equal @message, error_message
20
20
  assert_equal 'SemanticLogger::Appender::Sentry', hash[:extra][:name]
21
21
 
22
- if [:error, :fatal].include?(level)
23
- assert hash[:extra].has_key?(:backtrace)
22
+ if %i[error fatal].include?(level)
23
+ assert hash[:extra].key?(:backtrace)
24
24
  else
25
- refute hash[:extra].has_key?(:backtrace)
25
+ refute hash[:extra].key?(:backtrace)
26
26
  end
27
- assert_equal true, hash.has_key?(:extra)
27
+ assert_equal true, hash.key?(:extra)
28
28
  assert_equal level, hash[:level]
29
29
  end
30
30
 
31
31
  it "sends #{level} exceptions" do
32
32
  error = RuntimeError.new('Oh no, Error.')
33
33
  exception = hash = nil
34
- Raven.stub(:capture_exception, -> exc, h { exception = exc; hash = h }) do
34
+ Raven.stub(:capture_exception, ->(exc, h) { exception = exc; hash = h }) do
35
35
  @appender.send(level, @message, error)
36
36
  end
37
37
 
38
38
  assert_equal error.class.to_s, exception.class.to_s
39
39
  assert_equal error.message, exception.message
40
- assert_equal true, hash.has_key?(:extra)
40
+ assert_equal true, hash.key?(:extra)
41
41
  assert_equal @message, hash[:extra][:message], hash
42
42
  assert_equal level, hash[:level]
43
43
  end
44
44
  end
45
-
46
45
  end
47
46
  end
48
47
  end
@@ -19,7 +19,7 @@ module Appender
19
19
  SemanticLogger::LEVELS.each do |level|
20
20
  it "send #{level}" do
21
21
  request = nil
22
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
22
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
23
23
  @appender.send(level, @message)
24
24
  end
25
25
  body = decompress_data(request.body)
@@ -37,7 +37,7 @@ module Appender
37
37
  exc = e
38
38
  end
39
39
  request = nil
40
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
40
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
41
41
  @appender.send(level, 'Reading File', exc)
42
42
  end
43
43
  body = decompress_data(request.body)
@@ -52,8 +52,8 @@ module Appender
52
52
 
53
53
  it "sends #{level} custom attributes" do
54
54
  request = nil
55
- @appender.http.stub(:request, -> r { request = r; response_mock.new('200', 'ok') }) do
56
- @appender.send(level, @message, {key1: 1, key2: 'a'})
55
+ @appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
56
+ @appender.send(level, @message, key1: 1, key2: 'a')
57
57
  end
58
58
  body = decompress_data(request.body)
59
59
  message = JSON.parse(body)
@@ -4,7 +4,6 @@ require_relative '../test_helper'
4
4
  #
5
5
  module Appender
6
6
  class SplunkTest < Minitest::Test
7
-
8
7
  class Mock
9
8
  attr_accessor :message, :event
10
9
 
@@ -57,7 +56,7 @@ module Appender
57
56
  it "sends #{level} custom attributes" do
58
57
  mock = Mock.new
59
58
  @appender.stub(:service_index, mock) do
60
- @appender.send(level, @message, {key1: 1, key2: 'a'})
59
+ @appender.send(level, @message, key1: 1, key2: 'a')
61
60
  end
62
61
  assert_equal @message, mock.message
63
62
 
@@ -80,6 +79,5 @@ module Appender
80
79
  assert_nil mock.message
81
80
  end
82
81
  end
83
-
84
82
  end
85
83
  end
@@ -6,11 +6,10 @@ require 'net/tcp_client'
6
6
  module Appender
7
7
  class SyslogTest < Minitest::Test
8
8
  describe SemanticLogger::Appender::Syslog do
9
-
10
9
  it 'handle local syslog' do
11
10
  message = nil
12
11
  Syslog.stub(:open, nil) do
13
- Syslog.stub(:log, -> level, msg { message = msg }) do
12
+ Syslog.stub(:log, ->(_level, msg) { message = msg }) do
14
13
  syslog_appender = SemanticLogger::Appender::Syslog.new(level: :debug)
15
14
  syslog_appender.debug 'AppenderSyslogTest log message'
16
15
  end
@@ -23,7 +22,7 @@ module Appender
23
22
  Net::TCPClient.stub_any_instance(:closed?, false) do
24
23
  Net::TCPClient.stub_any_instance(:connect, nil) do
25
24
  syslog_appender = SemanticLogger::Appender::Syslog.new(url: 'tcp://localhost:88888', level: :debug)
26
- syslog_appender.remote_syslog.stub(:write, Proc.new { |data| message = data }) do
25
+ syslog_appender.remote_syslog.stub(:write, proc { |data| message = data }) do
27
26
  syslog_appender.debug 'AppenderSyslogTest log message'
28
27
  end
29
28
  end
@@ -34,7 +33,7 @@ module Appender
34
33
  it 'handle remote syslog over UDP' do
35
34
  message = nil
36
35
  syslog_appender = SemanticLogger::Appender::Syslog.new(url: 'udp://localhost:88888', level: :debug)
37
- UDPSocket.stub_any_instance(:send, -> msg, num, host, port { message = msg }) do
36
+ UDPSocket.stub_any_instance(:send, ->(msg, _num, _host, _port) { message = msg }) do
38
37
  syslog_appender.debug 'AppenderSyslogTest log message'
39
38
  end
40
39
  assert_match(/<70>(.*?)SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message/, message)
@@ -57,7 +56,6 @@ module Appender
57
56
  syslog_appender = SemanticLogger::Appender::Syslog.new
58
57
  syslog_appender.debug(message)
59
58
  end
60
-
61
59
  end
62
60
  end
63
61
  end
@@ -19,7 +19,7 @@ module Appender
19
19
  SemanticLogger::LEVELS.each do |level|
20
20
  it "send #{level}" do
21
21
  data = nil
22
- @appender.tcp_client.stub(:write, -> d { data = d }) do
22
+ @appender.tcp_client.stub(:write, ->(d) { data = d }) do
23
23
  @appender.send(level, @message)
24
24
  end
25
25
  hash = JSON.parse(data)
@@ -36,7 +36,7 @@ module Appender
36
36
  exc = e
37
37
  end
38
38
  data = nil
39
- @appender.tcp_client.stub(:write, -> d { data = d }) do
39
+ @appender.tcp_client.stub(:write, ->(d) { data = d }) do
40
40
  @appender.send(level, 'Reading File', exc)
41
41
  end
42
42
  hash = JSON.parse(data)
@@ -49,8 +49,8 @@ module Appender
49
49
 
50
50
  it "send #{level} custom attributes" do
51
51
  data = nil
52
- @appender.tcp_client.stub(:write, -> d { data = d }) do
53
- @appender.send(level, @message, {key1: 1, key2: 'a'})
52
+ @appender.tcp_client.stub(:write, ->(d) { data = d }) do
53
+ @appender.send(level, @message, key1: 1, key2: 'a')
54
54
  end
55
55
  hash = JSON.parse(data)
56
56
  assert_equal @message, hash['message']
@@ -60,7 +60,6 @@ module Appender
60
60
  assert_equal 1, payload['key1'], payload
61
61
  assert_equal 'a', payload['key2'], payload
62
62
  end
63
-
64
63
  end
65
64
  end
66
65
  end