logstash-logger 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +23 -0
- data/lib/logstash-logger/device/multi_delegator.rb +4 -2
- data/lib/logstash-logger/logger.rb +5 -1
- data/lib/logstash-logger/version.rb +1 -1
- data/spec/constructor_spec.rb +22 -0
- data/spec/device/multi_delegator_spec.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514e39db2da9a557f7ae7d76f0983d1d0df0ad0e
|
4
|
+
data.tar.gz: 5f1b91eaf92734f575210e0b47605d18b9e9a009
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd1f25d9c54d7819ffc8c5a8707de72df1f46ac61bf410c6f7777eb6364aca34378e7cce99701e69eeb8febb1a15e433af2fbac39bd74d43e9dcd068bbbcdb1
|
7
|
+
data.tar.gz: 19eff3e6e2b01ddf299060372dc6caeae1a9fe148f8bb04d2e8d3e10f93e16e80229a3ef1819dbb08a81eda59fd53b13cf2552ab1bd05078702b56b055cc3709
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.21.0
|
2
|
+
|
3
|
+
- Support for merging top level configuration in MultiLogger and
|
4
|
+
MultiDelegator. [#108](https://github.com/dwbutler/logstash-logger/pull/108)
|
5
|
+
|
1
6
|
## 0.20.1
|
2
7
|
|
3
8
|
- Fixes missing require for URI [#107](https://github.com/dwbutler/logstash-logger/pull/107)
|
data/README.md
CHANGED
@@ -238,6 +238,17 @@ This configuration would result in the following output.
|
|
238
238
|
}
|
239
239
|
```
|
240
240
|
|
241
|
+
This block has full access to the event, so you can remove fields, modify
|
242
|
+
existing fields, etc. For example, to remove the default timestamp:
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
config = LogStashLogger.configure do |config|
|
246
|
+
config.customize_event do |event|
|
247
|
+
event.remove('@timestamp')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
```
|
251
|
+
|
241
252
|
## Buffering / Automatic Retries
|
242
253
|
|
243
254
|
For devices that establish a connection to a remote service, log messages are buffered internally
|
@@ -269,6 +280,9 @@ Please be aware of the following caveats to this behavior:
|
|
269
280
|
immediately. In my testing, it took Ruby about 4 seconds to notice the receiving end was down
|
270
281
|
and start raising exceptions. Since logstash listeners over TCP/UDP do not acknowledge received
|
271
282
|
messages, it's not possible to know which log messages to re-send.
|
283
|
+
* When `sync` is turned off, Ruby may buffer data internally before writing to
|
284
|
+
the IO device. This is why you may not see messages written immediately to a
|
285
|
+
UDP or TCP socket, even though LogStashLogger's buffer is periodically flushed.
|
272
286
|
|
273
287
|
## Full Buffer
|
274
288
|
|
@@ -597,6 +611,14 @@ For a more detailed discussion of UDP vs TCP, I recommend reading this article:
|
|
597
611
|
|
598
612
|
## Troubleshooting
|
599
613
|
|
614
|
+
### Logstash never receives any logs
|
615
|
+
If you are using a device backed by a Ruby IO object (such as a file, UDP socket, or TCP socket), please be aware that Ruby
|
616
|
+
keeps its own internal buffer. Despite the fact that LogStashLogger buffers
|
617
|
+
messages and flushes them periodically, the data written to the IO object can
|
618
|
+
be buffered by Ruby internally indefinitely, and may not even write until the
|
619
|
+
program terminates. If this bothers you or you need to see log messages
|
620
|
+
immediately, your only recourse is to set the `sync: true` option.
|
621
|
+
|
600
622
|
### JSON::GeneratorError
|
601
623
|
Your application is probably attempting to log data that is not encoded in a valid way. When this happens, Ruby's
|
602
624
|
standard JSON library will raise an exception. You may be able to overcome this by swapping out a different JSON encoder
|
@@ -671,6 +693,7 @@ logger = LogStashLogger.new('localhost', 5228, :tcp)
|
|
671
693
|
* [Mike Gunderloy](https://github.com/ffmike)
|
672
694
|
* [Vitaly Gorodetsky](https://github.com/vitalis)
|
673
695
|
* [Courtland Caldwell](https://github.com/caldwecr)
|
696
|
+
* [Bibek Shrestha](https://github.com/bibstha)
|
674
697
|
|
675
698
|
## Contributing
|
676
699
|
|
@@ -10,14 +10,16 @@ module LogStashLogger
|
|
10
10
|
|
11
11
|
def initialize(opts)
|
12
12
|
@io = self
|
13
|
-
@devices = create_devices(opts
|
13
|
+
@devices = create_devices(opts)
|
14
14
|
self.class.delegate(:write, :close, :close!, :flush)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def create_devices(opts)
|
20
|
-
opts.
|
20
|
+
output_configurations = opts.delete(:outputs)
|
21
|
+
output_configurations.map do |device_opts|
|
22
|
+
device_opts = opts.merge(device_opts)
|
21
23
|
Device.new(device_opts)
|
22
24
|
end
|
23
25
|
end
|
@@ -72,7 +72,11 @@ module LogStashLogger
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.build_multi_logger(opts)
|
75
|
-
|
75
|
+
output_configurations = opts.delete(:outputs) || []
|
76
|
+
loggers = output_configurations.map do |config|
|
77
|
+
logger_opts = opts.merge(config)
|
78
|
+
build_logger(logger_opts)
|
79
|
+
end
|
76
80
|
MultiLogger.new(loggers)
|
77
81
|
end
|
78
82
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'logstash-logger'
|
2
|
+
|
3
|
+
describe LogStashLogger do
|
4
|
+
describe ".new" do
|
5
|
+
it "returns a Logger instance" do
|
6
|
+
expect(LogStashLogger.new(type: :stdout)).to be_a ::Logger
|
7
|
+
end
|
8
|
+
|
9
|
+
context "type: :multi_logger" do
|
10
|
+
it "returns an instance of LogStashLogger::MultiLogger" do
|
11
|
+
expect(LogStashLogger.new(type: :multi_logger)).to be_a LogStashLogger::MultiLogger
|
12
|
+
end
|
13
|
+
|
14
|
+
it "merges top level configuration into each logger" do
|
15
|
+
logger = LogStashLogger.new(type: :multi_logger, port: 1234, outputs: [ { type: :tcp }, { type: :udp } ])
|
16
|
+
logger.loggers.each do |logger|
|
17
|
+
expect(logger.device.port).to eq(1234)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -12,4 +12,20 @@ describe LogStashLogger::Device::MultiDelegator do
|
|
12
12
|
|
13
13
|
subject.write("test")
|
14
14
|
end
|
15
|
+
|
16
|
+
describe ".new" do
|
17
|
+
it "merges top level configuration to each output" do
|
18
|
+
logger = described_class.new(
|
19
|
+
port: 1234,
|
20
|
+
outputs: [
|
21
|
+
{ type: :udp },
|
22
|
+
{ type: :tcp }
|
23
|
+
]
|
24
|
+
)
|
25
|
+
|
26
|
+
logger.devices.each do |device|
|
27
|
+
expect(device.port).to eq(1234)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
15
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Butler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-event
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- samples/udp.conf
|
200
200
|
- samples/unix.conf
|
201
201
|
- spec/configuration_spec.rb
|
202
|
+
- spec/constructor_spec.rb
|
202
203
|
- spec/device/balancer_spec.rb
|
203
204
|
- spec/device/connectable_spec.rb
|
204
205
|
- spec/device/file_spec.rb
|
@@ -253,6 +254,7 @@ specification_version: 4
|
|
253
254
|
summary: LogStash Logger for ruby
|
254
255
|
test_files:
|
255
256
|
- spec/configuration_spec.rb
|
257
|
+
- spec/constructor_spec.rb
|
256
258
|
- spec/device/balancer_spec.rb
|
257
259
|
- spec/device/connectable_spec.rb
|
258
260
|
- spec/device/file_spec.rb
|