md-logstasher 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstasher/version.rb +1 -1
- data/lib/logstasher.rb +22 -0
- data/spec/lib/logstasher/logstasher_spec.rb +79 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0348868a167435982eb59967a93c089a748c0c186fd9e4047a64437e868b0023'
|
4
|
+
data.tar.gz: b5f0441ca7b83ce1a3aaf1bb0fab537fdab07a6d0c420f34ac75dbcbf426fbe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7b469e1c11272f3ebabdbf8b218068ca979342a9aa5d2a2e0ea5e7d20f723e369d2f4304fe72650e60af1b76dc8763fbb3764891453eb16622a5a7f6f563a4a
|
7
|
+
data.tar.gz: 84b8ca35715352709060707a86889dd3170985d2ed1224a55a583d478e73175b2d57f9d2b81c6a049d5801bbd56e92bbf7086b2c33f9e44f747c8627a20a4b9d
|
data/lib/logstasher/version.rb
CHANGED
data/lib/logstasher.rb
CHANGED
@@ -9,6 +9,28 @@ module LogStasher
|
|
9
9
|
attr_writer :serialize_parameters
|
10
10
|
attr_writer :silence_standard_logging
|
11
11
|
attr_accessor :metadata
|
12
|
+
attr_accessor :default_device
|
13
|
+
|
14
|
+
def load_from_config(config)
|
15
|
+
::LogStasher.logger = ::Logger.new("/dev/null")
|
16
|
+
|
17
|
+
config.each do |key,value|
|
18
|
+
key = key.to_s
|
19
|
+
case key
|
20
|
+
when 'metadata'
|
21
|
+
::LogStasher.metadata = value
|
22
|
+
when 'device'
|
23
|
+
::LogStasher.default_device = ::LogStasher::Device.factory(value)
|
24
|
+
::LogStasher.logger = ::Logger.new(::LogStasher.default_device)
|
25
|
+
when 'include_parameters'
|
26
|
+
::LogStasher.include_parameters = value
|
27
|
+
when 'serialize_parameters'
|
28
|
+
::LogStasher.serialize_parameters = value
|
29
|
+
when 'silence_standard_logging'
|
30
|
+
::LogStasher.silence_standard_logging = value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
12
34
|
|
13
35
|
def append_fields(&block)
|
14
36
|
@append_fields_callback = block
|
@@ -53,4 +53,83 @@ describe ::LogStasher do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
describe "#load_from_config" do
|
58
|
+
before(:each) do
|
59
|
+
::LogStasher.metadata = {}
|
60
|
+
::LogStasher.serialize_parameters = true
|
61
|
+
::LogStasher.silence_standard_logging = false
|
62
|
+
end
|
63
|
+
|
64
|
+
it "loads with multiple config keys" do
|
65
|
+
config = {
|
66
|
+
metadata: {
|
67
|
+
namespace: 'kirby',
|
68
|
+
logged_via: 'logstasher',
|
69
|
+
},
|
70
|
+
device: {
|
71
|
+
type: 'stdout'
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
::LogStasher.load_from_config(config)
|
76
|
+
expect(::LogStasher.metadata).to eq({:namespace => 'kirby', :logged_via => 'logstasher'})
|
77
|
+
expect(::LogStasher.default_device).to eq(STDOUT)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "loads metadata" do
|
81
|
+
config = {
|
82
|
+
metadata: {
|
83
|
+
namespace: 'kirby',
|
84
|
+
logged_via: 'logstasher',
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
::LogStasher.load_from_config(config)
|
89
|
+
expect(::LogStasher.metadata).to eq({:namespace => 'kirby', :logged_via => 'logstasher'})
|
90
|
+
end
|
91
|
+
|
92
|
+
it "loads parameters" do
|
93
|
+
config = {
|
94
|
+
include_parameters: false,
|
95
|
+
serialize_parameters: false,
|
96
|
+
silence_standard_logging: true,
|
97
|
+
silence_creation_message: false
|
98
|
+
}
|
99
|
+
|
100
|
+
::LogStasher.load_from_config(config)
|
101
|
+
expect(::LogStasher.instance_variable_get(:@include_parameters)).to be false
|
102
|
+
expect(::LogStasher.instance_variable_get(:@serialize_parameters)).to be false
|
103
|
+
expect(::LogStasher.instance_variable_get(:@silence_standard_logging)).to be true
|
104
|
+
end
|
105
|
+
|
106
|
+
it "loads with a stdout device" do
|
107
|
+
config = {
|
108
|
+
metadata: {
|
109
|
+
namespace: 'kirby',
|
110
|
+
logged_via: 'logstasher',
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
::LogStasher.load_from_config(config)
|
115
|
+
expect(::LogStasher.metadata).to eq({:namespace => 'kirby', :logged_via => 'logstasher'})
|
116
|
+
end
|
117
|
+
|
118
|
+
it "loads with a syslog device" do
|
119
|
+
config = {
|
120
|
+
device:
|
121
|
+
{
|
122
|
+
type: 'syslog',
|
123
|
+
identity: 'logstasher',
|
124
|
+
facility: 'LOG_LOCAL1',
|
125
|
+
priority: 'LOG_INFO',
|
126
|
+
flags: ['LOG_PID', 'LOG_CONS']
|
127
|
+
}
|
128
|
+
}
|
129
|
+
::LogStasher.load_from_config(config)
|
130
|
+
expect(::LogStasher.metadata).to eq({})
|
131
|
+
expect(::LogStasher.default_device).to be_a ::LogStasher::Device::Syslog
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
56
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: md-logstasher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devin Christensen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-event
|
@@ -108,7 +108,7 @@ homepage: https://github.com/moneydesktop/logstasher
|
|
108
108
|
licenses:
|
109
109
|
- MIT
|
110
110
|
metadata: {}
|
111
|
-
post_install_message:
|
111
|
+
post_install_message:
|
112
112
|
rdoc_options: []
|
113
113
|
require_paths:
|
114
114
|
- lib
|
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
126
|
+
rubygems_version: 3.4.21
|
127
|
+
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Awesome rails logs
|
130
130
|
test_files:
|