semantic_logger 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/semantic_logger.rb +7 -1
- data/lib/semantic_logger/appender.rb +3 -0
- data/lib/semantic_logger/appender/async.rb +29 -10
- data/lib/semantic_logger/appender/rabbitmq.rb +120 -0
- data/lib/semantic_logger/appenders.rb +89 -0
- data/lib/semantic_logger/base.rb +3 -3
- data/lib/semantic_logger/concerns/compatibility.rb +2 -2
- data/lib/semantic_logger/formatters.rb +1 -0
- data/lib/semantic_logger/formatters/base.rb +28 -6
- data/lib/semantic_logger/formatters/color.rb +4 -3
- data/lib/semantic_logger/formatters/fluentd.rb +37 -0
- data/lib/semantic_logger/formatters/json.rb +4 -2
- data/lib/semantic_logger/formatters/raw.rb +2 -2
- data/lib/semantic_logger/formatters/signalfx.rb +4 -3
- data/lib/semantic_logger/levels.rb +38 -0
- data/lib/semantic_logger/log.rb +11 -6
- data/lib/semantic_logger/loggable.rb +1 -1
- data/lib/semantic_logger/logger.rb +43 -1
- data/lib/semantic_logger/processor.rb +10 -130
- data/lib/semantic_logger/reporters/minitest.rb +49 -0
- data/lib/semantic_logger/semantic_logger.rb +40 -75
- data/lib/semantic_logger/version.rb +1 -1
- metadata +9 -81
- data/test/appender/async_batch_test.rb +0 -60
- data/test/appender/async_test.rb +0 -44
- data/test/appender/bugsnag_test.rb +0 -81
- data/test/appender/elasticsearch_http_test.rb +0 -74
- data/test/appender/elasticsearch_test.rb +0 -248
- data/test/appender/file_test.rb +0 -120
- data/test/appender/graylog_test.rb +0 -82
- data/test/appender/honeybadger_test.rb +0 -45
- data/test/appender/http_test.rb +0 -63
- data/test/appender/kafka_test.rb +0 -35
- data/test/appender/mongodb_test.rb +0 -104
- data/test/appender/new_relic_test.rb +0 -80
- data/test/appender/newrelic_rpm.rb +0 -14
- data/test/appender/sentry_test.rb +0 -47
- data/test/appender/splunk_http_test.rb +0 -79
- data/test/appender/splunk_test.rb +0 -83
- data/test/appender/syslog_test.rb +0 -61
- data/test/appender/tcp_test.rb +0 -66
- data/test/appender/udp_test.rb +0 -59
- data/test/appender/wrapper_test.rb +0 -95
- data/test/concerns/compatibility_test.rb +0 -117
- data/test/debug_as_trace_logger_test.rb +0 -81
- data/test/formatters/color_test.rb +0 -153
- data/test/formatters/default_test.rb +0 -175
- data/test/formatters/one_line_test.rb +0 -60
- data/test/formatters/signalfx_test.rb +0 -197
- data/test/formatters_test.rb +0 -36
- data/test/in_memory_appender.rb +0 -8
- data/test/in_memory_appender_helper.rb +0 -43
- data/test/in_memory_batch_appender.rb +0 -8
- data/test/in_memory_metrics_appender.rb +0 -13
- data/test/loggable_test.rb +0 -103
- data/test/logger_test.rb +0 -334
- data/test/measure_test.rb +0 -346
- data/test/metric/new_relic_test.rb +0 -35
- data/test/metric/signalfx_test.rb +0 -77
- data/test/semantic_logger_test.rb +0 -303
- data/test/test_helper.rb +0 -31
@@ -1,82 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Graylog
|
4
|
-
module Appender
|
5
|
-
class GraylogTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::Graylog do
|
7
|
-
before do
|
8
|
-
@appender = SemanticLogger::Appender::Graylog.new(level: :info)
|
9
|
-
@message = 'AppenderGraylogTest log message'
|
10
|
-
end
|
11
|
-
|
12
|
-
(SemanticLogger::LEVELS - %i[info warn error fatal]).each do |level|
|
13
|
-
it "not send :#{level} notifications to Graylog" do
|
14
|
-
hash = nil
|
15
|
-
@appender.notifier.stub(:notify!, ->(h) { hash = h }) do
|
16
|
-
@appender.send(level, "AppenderGraylogTest #{level} message")
|
17
|
-
end
|
18
|
-
assert_nil hash
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'send exception notifications to Graylog with severity' do
|
23
|
-
hash = nil
|
24
|
-
exc = nil
|
25
|
-
begin
|
26
|
-
Uh oh
|
27
|
-
rescue Exception => e
|
28
|
-
exc = e
|
29
|
-
end
|
30
|
-
@appender.notifier.stub(:notify!, ->(h) { hash = h }) do
|
31
|
-
@appender.error 'Reading File', exc
|
32
|
-
end
|
33
|
-
assert_equal 'Reading File', hash[:short_message]
|
34
|
-
assert_equal 'NameError', hash[:exception][:name]
|
35
|
-
assert_match 'undefined local variable or method', hash[:exception][:message]
|
36
|
-
assert_equal 3, hash[:level], 'Should be error level (3)'
|
37
|
-
assert hash[:exception][:stack_trace].first.include?(__FILE__), hash[:exception]
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'send exception notifications to Graylog without log message' do
|
41
|
-
hash = nil
|
42
|
-
exc = nil
|
43
|
-
begin
|
44
|
-
raise StandardError, 'Reading File'
|
45
|
-
rescue Exception => e
|
46
|
-
exc = e
|
47
|
-
end
|
48
|
-
@appender.notifier.stub(:notify!, ->(h) { hash = h }) do
|
49
|
-
@appender.error exc
|
50
|
-
end
|
51
|
-
assert_equal exc.message, hash[:short_message]
|
52
|
-
assert_equal exc.class.to_s, hash[:exception][:name]
|
53
|
-
assert_match exc.message, hash[:exception][:message]
|
54
|
-
assert_equal 3, hash[:level], 'Should be error level (3)'
|
55
|
-
assert hash[:exception][:stack_trace].first.include?(__FILE__), hash[:exception]
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'send error notifications to Graylog with severity' do
|
59
|
-
hash = nil
|
60
|
-
@appender.notifier.stub(:notify!, ->(h) { hash = h }) do
|
61
|
-
@appender.error @message
|
62
|
-
end
|
63
|
-
assert_equal @message, hash[:short_message]
|
64
|
-
assert_equal 3, hash[:level]
|
65
|
-
refute hash[:stack_trace]
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'send notification to Graylog with custom attributes' do
|
69
|
-
hash = nil
|
70
|
-
@appender.notifier.stub(:notify!, ->(h) { hash = h }) do
|
71
|
-
@appender.error @message, key1: 1, key2: 'a'
|
72
|
-
end
|
73
|
-
assert_equal @message, hash[:short_message]
|
74
|
-
assert_equal 3, hash[:level]
|
75
|
-
refute hash[:stack_trace]
|
76
|
-
assert payload = hash[:payload], hash
|
77
|
-
assert_equal 1, payload[:key1], payload
|
78
|
-
assert_equal 'a', payload[:key2], payload
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Bugsnag
|
4
|
-
module Appender
|
5
|
-
class HoneybadgerTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::Honeybadger do
|
7
|
-
before do
|
8
|
-
@appender = SemanticLogger::Appender::Honeybadger.new(level: :trace)
|
9
|
-
@message = 'AppenderHoneybadgerTest log message'
|
10
|
-
SemanticLogger.backtrace_level = :error
|
11
|
-
end
|
12
|
-
|
13
|
-
SemanticLogger::LEVELS.each do |level|
|
14
|
-
it "sends #{level} message" do
|
15
|
-
hash = nil
|
16
|
-
Honeybadger.stub(:notify, ->(h) { hash = h }) do
|
17
|
-
@appender.send(level, @message)
|
18
|
-
end
|
19
|
-
assert_equal @message, hash[:error_message]
|
20
|
-
assert_equal 'SemanticLogger::Appender::Honeybadger', hash[:error_class]
|
21
|
-
|
22
|
-
if %i[error fatal].include?(level)
|
23
|
-
assert hash.key?(:backtrace)
|
24
|
-
else
|
25
|
-
refute hash.key?(:backtrace)
|
26
|
-
end
|
27
|
-
assert_equal true, hash.key?(:context)
|
28
|
-
assert_equal level, hash[:context][:level]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sends #{level} exceptions" do
|
32
|
-
error = RuntimeError.new('Oh no, Error.')
|
33
|
-
exception = hash = nil
|
34
|
-
Honeybadger.stub(:notify, ->(exc, h) { exception = exc; hash = h }) do
|
35
|
-
@appender.send(level, @message, error)
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_equal error.class.to_s, exception.class.to_s
|
39
|
-
assert_equal error.message, exception.message
|
40
|
-
assert_equal @message, hash[:message], hash
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/test/appender/http_test.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Http
|
4
|
-
module Appender
|
5
|
-
class HttpTest < Minitest::Test
|
6
|
-
response_mock = Struct.new(:code, :body)
|
7
|
-
|
8
|
-
describe SemanticLogger::Appender::Http do
|
9
|
-
before do
|
10
|
-
Net::HTTP.stub_any_instance(:start, true) do
|
11
|
-
@appender = SemanticLogger::Appender::Http.new(url: 'http://localhost:8088/path')
|
12
|
-
end
|
13
|
-
@message = 'AppenderHttpTest log message'
|
14
|
-
end
|
15
|
-
|
16
|
-
SemanticLogger::LEVELS.each do |level|
|
17
|
-
it "send #{level}" do
|
18
|
-
request = nil
|
19
|
-
@appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
|
20
|
-
@appender.send(level, @message)
|
21
|
-
end
|
22
|
-
hash = JSON.parse(request.body)
|
23
|
-
assert_equal @message, hash['message']
|
24
|
-
assert_equal level.to_s, hash['level']
|
25
|
-
refute hash['stack_trace']
|
26
|
-
end
|
27
|
-
|
28
|
-
it "send #{level} exceptions" do
|
29
|
-
exc = nil
|
30
|
-
begin
|
31
|
-
Uh oh
|
32
|
-
rescue Exception => e
|
33
|
-
exc = e
|
34
|
-
end
|
35
|
-
request = nil
|
36
|
-
@appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
|
37
|
-
@appender.send(level, 'Reading File', exc)
|
38
|
-
end
|
39
|
-
hash = JSON.parse(request.body)
|
40
|
-
assert 'Reading File', hash['message']
|
41
|
-
assert 'NameError', hash['exception']['name']
|
42
|
-
assert 'undefined local variable or method', hash['exception']['message']
|
43
|
-
assert_equal level.to_s, hash['level'], 'Should be error level (3)'
|
44
|
-
assert hash['exception']['stack_trace'].first.include?(__FILE__), hash['exception']
|
45
|
-
end
|
46
|
-
|
47
|
-
it "send #{level} custom attributes" do
|
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')
|
51
|
-
end
|
52
|
-
hash = JSON.parse(request.body)
|
53
|
-
assert_equal @message, hash['message']
|
54
|
-
assert_equal level.to_s, hash['level']
|
55
|
-
refute hash['stack_trace']
|
56
|
-
assert payload = hash['payload'], hash
|
57
|
-
assert_equal 1, payload['key1'], payload
|
58
|
-
assert_equal 'a', payload['key2'], payload
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/test/appender/kafka_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
module Appender
|
4
|
-
class KafkaTest < Minitest::Test
|
5
|
-
describe SemanticLogger::Appender::Kafka do
|
6
|
-
before do
|
7
|
-
@appender = SemanticLogger::Appender::Kafka.new(
|
8
|
-
seed_brokers: ['localhost:9092']
|
9
|
-
)
|
10
|
-
@message = 'AppenderKafkaTest log message'
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@appender&.close
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'sends log messages in JSON format' do
|
18
|
-
message = nil
|
19
|
-
options = nil
|
20
|
-
::Kafka::Producer.stub_any_instance(:produce, ->(value, **opts) { message = value; options = opts }) do
|
21
|
-
@appender.info(@message)
|
22
|
-
@appender.flush
|
23
|
-
end
|
24
|
-
|
25
|
-
h = JSON.parse(message)
|
26
|
-
assert_equal 'info', h['level']
|
27
|
-
assert_equal @message, h['message']
|
28
|
-
assert_equal 'SemanticLogger::Appender::Kafka', h['name']
|
29
|
-
assert_equal $$, h['pid']
|
30
|
-
|
31
|
-
assert_equal 'log_messages', options[:topic]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::MongoDB
|
4
|
-
module Appender
|
5
|
-
class MongoDBTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::MongoDB do
|
7
|
-
before do
|
8
|
-
@appender = SemanticLogger::Appender::MongoDB.new(
|
9
|
-
uri: 'mongodb://127.0.0.1:27017/test',
|
10
|
-
collection_size: 10 * 1024 ** 2, # 10MB
|
11
|
-
host: 'test',
|
12
|
-
application: 'test_application',
|
13
|
-
level: :trace
|
14
|
-
)
|
15
|
-
@hash = {tracking_number: 12_345, session_id: 'HSSKLEU@JDK767'}
|
16
|
-
Thread.current.name = 'thread'
|
17
|
-
end
|
18
|
-
|
19
|
-
after do
|
20
|
-
@appender&.purge_all
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'format logs into documents' do
|
24
|
-
it 'handle no arguments' do
|
25
|
-
@appender.debug
|
26
|
-
document = @appender.collection.find.first
|
27
|
-
assert_equal :debug, document['level']
|
28
|
-
assert_nil document['message']
|
29
|
-
assert_equal 'thread', document['thread']
|
30
|
-
assert document['time'].is_a?(Time)
|
31
|
-
assert_nil document['payload']
|
32
|
-
assert_equal $$, document['pid']
|
33
|
-
assert_equal 'test', document['host']
|
34
|
-
assert_equal 'test_application', document['application']
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'handle named parameters' do
|
38
|
-
@appender.debug(payload: @hash)
|
39
|
-
|
40
|
-
document = @appender.collection.find.first
|
41
|
-
assert_equal :debug, document['level']
|
42
|
-
assert_nil document['message']
|
43
|
-
assert_equal 'thread', document['thread']
|
44
|
-
assert document['time'].is_a?(Time)
|
45
|
-
assert payload = document['payload']
|
46
|
-
assert_equal 12_345, payload['tracking_number'], payload
|
47
|
-
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
48
|
-
assert_equal $$, document['pid']
|
49
|
-
assert_equal 'test', document['host']
|
50
|
-
assert_equal 'test_application', document['application']
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'handle message and payload' do
|
54
|
-
@appender.debug('hello world', @hash)
|
55
|
-
|
56
|
-
document = @appender.collection.find.first
|
57
|
-
assert_equal :debug, document['level']
|
58
|
-
assert_equal 'hello world', document['message']
|
59
|
-
assert_equal 'thread', document['thread']
|
60
|
-
assert document['time'].is_a?(Time)
|
61
|
-
assert payload = document['payload']
|
62
|
-
assert_equal 12_345, payload['tracking_number'], payload
|
63
|
-
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
64
|
-
assert_equal $$, document['pid']
|
65
|
-
assert_equal 'test', document['host']
|
66
|
-
assert_equal 'test_application', document['application']
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'handle message without payload' do
|
70
|
-
@appender.debug('hello world')
|
71
|
-
|
72
|
-
document = @appender.collection.find.first
|
73
|
-
assert_equal :debug, document['level']
|
74
|
-
assert_equal 'hello world', document['message']
|
75
|
-
assert_equal 'thread', document['thread']
|
76
|
-
assert document['time'].is_a?(Time)
|
77
|
-
assert_equal $$, document['pid']
|
78
|
-
assert_equal 'test', document['host']
|
79
|
-
assert_equal 'test_application', document['application']
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Ensure that any log level can be logged
|
84
|
-
SemanticLogger::LEVELS.each do |level|
|
85
|
-
describe "##{level}" do
|
86
|
-
it 'logs' do
|
87
|
-
@appender.send(level, 'hello world -- Calculations', @hash)
|
88
|
-
document = @appender.collection.find.first
|
89
|
-
assert_equal level, document['level']
|
90
|
-
assert_equal 'hello world -- Calculations', document['message']
|
91
|
-
assert_equal 'thread', document['thread']
|
92
|
-
assert document['time'].is_a?(Time)
|
93
|
-
assert payload = document['payload']
|
94
|
-
assert_equal 12_345, payload['tracking_number'], payload
|
95
|
-
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
96
|
-
assert_equal $$, document['pid']
|
97
|
-
assert_equal 'test', document['host'], document.ai
|
98
|
-
assert_equal 'test_application', document['application']
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# So that the NewRelic appender will load the mock
|
2
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
-
require_relative '../test_helper'
|
4
|
-
|
5
|
-
# Unit Test for SemanticLogger::Appender::NewRelic
|
6
|
-
module Appender
|
7
|
-
class NewRelicTest < Minitest::Test
|
8
|
-
describe SemanticLogger::Appender::NewRelic do
|
9
|
-
before do
|
10
|
-
@appender = SemanticLogger::Appender::NewRelic.new
|
11
|
-
@message = 'AppenderNewRelicTest log message'
|
12
|
-
end
|
13
|
-
|
14
|
-
(SemanticLogger::LEVELS - %i[error fatal]).each do |level|
|
15
|
-
it "does not send :#{level} notifications to New Relic" do
|
16
|
-
exception = hash = nil
|
17
|
-
NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
|
18
|
-
@appender.tagged('test') do
|
19
|
-
@appender.send(level, "AppenderNewRelicTest #{level} message")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
assert_nil exception
|
23
|
-
assert_nil hash
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
%i[error fatal].each do |level|
|
28
|
-
it "sends :#{level} notifications to New Relic" do
|
29
|
-
exception = hash = nil
|
30
|
-
NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
|
31
|
-
@appender.tagged('test') do
|
32
|
-
@appender.send(level, @message)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
assert_equal 'RuntimeError', exception.class.to_s
|
36
|
-
assert_equal @message, exception.message
|
37
|
-
assert_equal ['test'], hash[:custom_params][:tags]
|
38
|
-
assert_nil hash[:custom_params][:duration]
|
39
|
-
assert hash[:custom_params][:thread], hash.inspect
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'send notification to New Relic with custom attributes' do
|
44
|
-
exception = hash = nil
|
45
|
-
NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
|
46
|
-
SemanticLogger.tagged('test') do
|
47
|
-
SemanticLogger.named_tagged(key1: 1, key2: 'a') do
|
48
|
-
@appender.measure_error(message: @message, payload: {key3: 4}) do
|
49
|
-
sleep 0.001
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
assert_equal 'RuntimeError', exception.class.to_s
|
55
|
-
assert_equal @message, exception.message
|
56
|
-
assert params = hash[:custom_params], hash
|
57
|
-
assert params[:duration], params
|
58
|
-
assert params[:thread], params
|
59
|
-
|
60
|
-
assert_equal ['test'], params[:tags], params
|
61
|
-
|
62
|
-
assert named_tags = params[:named_tags], params
|
63
|
-
assert_equal 1, named_tags[:key1], named_tags
|
64
|
-
assert_equal 'a', named_tags[:key2], named_tags
|
65
|
-
|
66
|
-
assert payload = params[:payload], params
|
67
|
-
assert_equal 4, payload[:key3], payload
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'does not send metric only notifications' do
|
71
|
-
exception = hash = nil
|
72
|
-
NewRelic::Agent.stub(:notice_error, ->(exc, h) { exception = exc; hash = h }) do
|
73
|
-
@appender.debug metric: 'my/custom/metric', payload: {hello: :world}
|
74
|
-
end
|
75
|
-
assert_nil exception
|
76
|
-
assert_nil hash
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Sentry
|
4
|
-
module Appender
|
5
|
-
class SentryTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::Sentry do
|
7
|
-
before do
|
8
|
-
@appender = SemanticLogger::Appender::Sentry.new(level: :trace)
|
9
|
-
@message = 'AppenderRavenTest log message'
|
10
|
-
SemanticLogger.backtrace_level = :error
|
11
|
-
end
|
12
|
-
|
13
|
-
SemanticLogger::LEVELS.each do |level|
|
14
|
-
it "sends #{level} message" do
|
15
|
-
error_message = hash = nil
|
16
|
-
Raven.stub(:capture_message, ->(msg, h) { error_message = msg; hash = h }) do
|
17
|
-
@appender.send(level, @message)
|
18
|
-
end
|
19
|
-
assert_equal @message, error_message
|
20
|
-
assert_equal 'SemanticLogger::Appender::Sentry', hash[:extra][:name]
|
21
|
-
|
22
|
-
if %i[error fatal].include?(level)
|
23
|
-
assert hash[:extra].key?(:backtrace)
|
24
|
-
else
|
25
|
-
refute hash[:extra].key?(:backtrace)
|
26
|
-
end
|
27
|
-
assert_equal true, hash.key?(:extra)
|
28
|
-
assert_equal level, hash[:level]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sends #{level} exceptions" do
|
32
|
-
error = RuntimeError.new('Oh no, Error.')
|
33
|
-
exception = hash = nil
|
34
|
-
Raven.stub(:capture_exception, ->(exc, h) { exception = exc; hash = h }) do
|
35
|
-
@appender.send(level, @message, error)
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_equal error.class.to_s, exception.class.to_s
|
39
|
-
assert_equal error.message, exception.message
|
40
|
-
assert_equal true, hash.key?(:extra)
|
41
|
-
assert_equal @message, hash[:extra][:message], hash
|
42
|
-
assert_equal level, hash[:level]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|