md-logstasher 1.6.0 → 1.7.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 +9 -7
- data/spec/lib/logstasher/logstasher_spec.rb +8 -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: 69eb9914c59b6fdde645a4c54c51785fbe677f287c18e462f4283dac2af7ef70
|
4
|
+
data.tar.gz: c5a6066a51d68cbfa123c8bd1e30138ee90efac02a8a19cf7ed1da56e68d09f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89642d029ce8980eeb786953c580ab5574122a3bec77c096611c9a0c380b6230924375bf972b48f36af28134ac1474945a6c53983368eb0184d3246cb18b2ca2
|
7
|
+
data.tar.gz: b38aced68aa13148b72539aac1aeca810bd10b34558e776c06a0400195675ab387b86c19b463b572a59c6704cb24280db7c38c06dfa3ffc17d295e2bed075387
|
data/lib/logstasher/version.rb
CHANGED
data/lib/logstasher.rb
CHANGED
@@ -46,18 +46,20 @@ module LogStasher
|
|
46
46
|
|
47
47
|
def log_as_json(payload, as_logstash_event: false)
|
48
48
|
payload = payload.dup
|
49
|
-
|
49
|
+
|
50
|
+
# Merge in metadata if configured. This supports a Hash and a fully formed
|
51
|
+
# LogStash::Event.
|
52
|
+
if !metadata.empty?
|
53
|
+
payload.merge!(:metadata => metadata) if payload.is_a?(::Hash)
|
54
|
+
payload.append(:metadata => metadata) if payload.is_a?(::LogStash::Event)
|
55
|
+
end
|
50
56
|
|
51
57
|
# Wrap the hash in a logstash event if the caller wishes for a specific
|
52
58
|
# formatting applied to the hash. This is used by log subscriber, for
|
53
59
|
# example.
|
54
|
-
|
55
|
-
::LogStash::Event.new(payload).to_json
|
56
|
-
else
|
57
|
-
payload.to_json
|
58
|
-
end
|
60
|
+
payload = ::LogStash::Event.new(payload) if as_logstash_event
|
59
61
|
|
60
|
-
logger <<
|
62
|
+
logger << payload.to_json + $INPUT_RECORD_SEPARATOR
|
61
63
|
end
|
62
64
|
|
63
65
|
def logger
|
@@ -36,6 +36,14 @@ describe ::LogStasher do
|
|
36
36
|
::LogStasher.log_as_json(:yolo => :brolo)
|
37
37
|
end
|
38
38
|
|
39
|
+
it "merges metadata for LogStash::Event types" do
|
40
|
+
expect(::LogStasher.logger).to receive(:<<) do |json|
|
41
|
+
expect(::JSON.parse(json)).to match(a_hash_including("yolo" => "brolo", "metadata" => { "namespace" => "cooldude" }))
|
42
|
+
end
|
43
|
+
|
44
|
+
::LogStasher.log_as_json(::LogStash::Event.new(:yolo => :brolo))
|
45
|
+
end
|
46
|
+
|
39
47
|
it "does not merge metadata on an array" do
|
40
48
|
expect(::LogStasher.logger).to receive(:<<) do |json|
|
41
49
|
expect(::JSON.parse(json)).to eq([{ "yolo" => "brolo" }])
|
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.7.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: 2023-01-07 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.1.6
|
127
|
+
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Awesome rails logs
|
130
130
|
test_files:
|