logasm-jruby 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +8 -0
- data/README.md +121 -0
- data/Rakefile +7 -0
- data/benchmark/whitelisting.rb +53 -0
- data/lib/logasm.rb +74 -0
- data/lib/logasm/adapters.rb +22 -0
- data/lib/logasm/adapters/stdout_adapter.rb +29 -0
- data/lib/logasm/adapters/stdout_json_adapter.rb +44 -0
- data/lib/logasm/null_logger.rb +18 -0
- data/lib/logasm/preprocessors.rb +18 -0
- data/lib/logasm/preprocessors/blacklist.rb +61 -0
- data/lib/logasm/preprocessors/json_pointer_trie.rb +40 -0
- data/lib/logasm/preprocessors/strategies/mask.rb +43 -0
- data/lib/logasm/preprocessors/strategies/prune.rb +44 -0
- data/lib/logasm/preprocessors/whitelist.rb +56 -0
- data/lib/logasm/utils.rb +91 -0
- data/logasm.gemspec +36 -0
- data/spec/adapters/stdout_adapter_spec.rb +48 -0
- data/spec/adapters/stdout_json_adapter_spec.rb +43 -0
- data/spec/logasm_spec.rb +142 -0
- data/spec/preprocessors/blacklist_spec.rb +131 -0
- data/spec/preprocessors/json_pointer_trie.rb +36 -0
- data/spec/preprocessors/whitelist_spec.rb +335 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/implement_interface.rb +11 -0
- data/spec/utils_spec.rb +84 -0
- metadata +168 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'pry'
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
require 'logasm'
|
7
|
+
|
8
|
+
Dir[File.dirname(__FILE__) + '/support/*.rb'].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
config.order = 'random'
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
RSpec::Matchers.define :implement_interface do |expected|
|
2
|
+
required_methods = expected.instance_methods(false)
|
3
|
+
match do |actual|
|
4
|
+
required_methods - actual.methods == []
|
5
|
+
end
|
6
|
+
|
7
|
+
failure_message do |actual|
|
8
|
+
missing_methods = required_methods - actual.methods
|
9
|
+
"Expected instance methods #{missing_methods.inspect} to be implemented"
|
10
|
+
end
|
11
|
+
end
|
data/spec/utils_spec.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Logasm::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
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logasm-jruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Salemove
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: lru_redux
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: jrjackson
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
name: bundler
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
name: rake
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: bunny
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
name: benchmark-ips
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: It's logasmic
|
98
|
+
email:
|
99
|
+
- support@salemove.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".ruby-gemset"
|
107
|
+
- ".ruby-version"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- benchmark/whitelisting.rb
|
113
|
+
- lib/logasm.rb
|
114
|
+
- lib/logasm/adapters.rb
|
115
|
+
- lib/logasm/adapters/stdout_adapter.rb
|
116
|
+
- lib/logasm/adapters/stdout_json_adapter.rb
|
117
|
+
- lib/logasm/null_logger.rb
|
118
|
+
- lib/logasm/preprocessors.rb
|
119
|
+
- lib/logasm/preprocessors/blacklist.rb
|
120
|
+
- lib/logasm/preprocessors/json_pointer_trie.rb
|
121
|
+
- lib/logasm/preprocessors/strategies/mask.rb
|
122
|
+
- lib/logasm/preprocessors/strategies/prune.rb
|
123
|
+
- lib/logasm/preprocessors/whitelist.rb
|
124
|
+
- lib/logasm/utils.rb
|
125
|
+
- logasm.gemspec
|
126
|
+
- spec/adapters/stdout_adapter_spec.rb
|
127
|
+
- spec/adapters/stdout_json_adapter_spec.rb
|
128
|
+
- spec/logasm_spec.rb
|
129
|
+
- spec/preprocessors/blacklist_spec.rb
|
130
|
+
- spec/preprocessors/json_pointer_trie.rb
|
131
|
+
- spec/preprocessors/whitelist_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/support/implement_interface.rb
|
134
|
+
- spec/utils_spec.rb
|
135
|
+
homepage:
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.6.13
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: What description said
|
159
|
+
test_files:
|
160
|
+
- spec/adapters/stdout_adapter_spec.rb
|
161
|
+
- spec/adapters/stdout_json_adapter_spec.rb
|
162
|
+
- spec/logasm_spec.rb
|
163
|
+
- spec/preprocessors/blacklist_spec.rb
|
164
|
+
- spec/preprocessors/json_pointer_trie.rb
|
165
|
+
- spec/preprocessors/whitelist_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
- spec/support/implement_interface.rb
|
168
|
+
- spec/utils_spec.rb
|