lenjador 1.2.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +41 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -3
- data/Gemfile +1 -6
- data/Rakefile +6 -4
- data/benchmark/whitelisting.rb +7 -7
- data/lenjador.gemspec +21 -26
- data/lib/lenjador.rb +38 -23
- data/lib/lenjador/adapters.rb +9 -14
- data/lib/lenjador/adapters/stdout_adapter.rb +6 -9
- data/lib/lenjador/adapters/stdout_json_adapter.rb +10 -36
- data/lib/lenjador/null_logger.rb +7 -10
- data/lib/lenjador/preprocessors.rb +2 -0
- data/lib/lenjador/preprocessors/blacklist.rb +11 -9
- data/lib/lenjador/preprocessors/json_pointer_trie.rb +4 -2
- data/lib/lenjador/preprocessors/strategies/mask.rb +3 -1
- data/lib/lenjador/preprocessors/strategies/prune.rb +2 -0
- data/lib/lenjador/preprocessors/whitelist.rb +6 -6
- data/lib/lenjador/utils.rb +42 -43
- data/profiler/logs.rb +19 -0
- data/spec/lenjador/adapters/stdout_adapter_spec.rb +48 -0
- data/spec/lenjador/adapters/stdout_json_adapter_spec.rb +46 -0
- data/spec/{preprocessors → lenjador/preprocessors}/blacklist_spec.rb +18 -14
- data/spec/{preprocessors/json_pointer_trie.rb → lenjador/preprocessors/json_pointer_trie_spec.rb} +4 -4
- data/spec/lenjador/preprocessors/whitelist_spec.rb +319 -0
- data/spec/lenjador/utils_spec.rb +99 -0
- data/spec/lenjador_spec.rb +41 -33
- data/spec/spec_helper.rb +1 -1
- metadata +67 -24
- data/spec/adapters/stdout_adapter_spec.rb +0 -48
- data/spec/adapters/stdout_json_adapter_spec.rb +0 -62
- data/spec/preprocessors/whitelist_spec.rb +0 -335
- data/spec/utils_spec.rb +0 -84
data/spec/utils_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Lenjador::Utils do
|
4
|
-
let(:now) { Time.utc(2015, 10, 11, 23, 10, 21, 123456) }
|
5
|
-
|
6
|
-
before do
|
7
|
-
allow(Time).to receive(:now) { now }
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '.build_event' do
|
11
|
-
subject(:event) { described_class.build_event(metadata, level, application_name) }
|
12
|
-
|
13
|
-
let(:application_name) { 'test_service' }
|
14
|
-
let(:level) { :info }
|
15
|
-
let(:metadata) { {x: 'y'} }
|
16
|
-
|
17
|
-
it 'includes it in the event as application' do
|
18
|
-
expect(event[:application]).to eq(application_name)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'includes log level' do
|
22
|
-
expect(event[:level]).to eq(:info)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'includes timestamp' do
|
26
|
-
expect(event[:@timestamp]).to eq('2015-10-11T23:10:21.123Z')
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when @timestamp provided' do
|
30
|
-
let(:metadata) { {message: 'test', :@timestamp => 'a timestamp'} }
|
31
|
-
|
32
|
-
it 'overwrites @timestamp' do
|
33
|
-
expect(subject[:message]).to eq('test')
|
34
|
-
expect(subject[:@timestamp]).to eq('a timestamp')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when host provided' do
|
39
|
-
let(:metadata) { {message: 'test', host: 'xyz'} }
|
40
|
-
|
41
|
-
it 'overwrites host' do
|
42
|
-
expect(subject[:message]).to eq('test')
|
43
|
-
expect(subject[:host]).to eq('xyz')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.serialize_time_objects!' do
|
49
|
-
let(:object) do
|
50
|
-
{
|
51
|
-
time: Time.now,
|
52
|
-
hash: {
|
53
|
-
time: Time.now
|
54
|
-
},
|
55
|
-
array: [
|
56
|
-
Time.now,
|
57
|
-
{
|
58
|
-
time: Time.now
|
59
|
-
}
|
60
|
-
]
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
let(:serialized_time) { now.iso8601 }
|
65
|
-
|
66
|
-
it 'recursively serializes time objects to iso8601' do
|
67
|
-
o = object.dup
|
68
|
-
described_class.serialize_time_objects!(o)
|
69
|
-
|
70
|
-
expect(o).to eq(
|
71
|
-
time: serialized_time,
|
72
|
-
hash: {
|
73
|
-
time: serialized_time
|
74
|
-
},
|
75
|
-
array: [
|
76
|
-
serialized_time,
|
77
|
-
{
|
78
|
-
time: serialized_time
|
79
|
-
}
|
80
|
-
]
|
81
|
-
)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|