logplex 0.0.1 → 0.0.5
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 +5 -5
- data/lib/logplex/publisher.rb +4 -3
- data/lib/logplex/version.rb +1 -1
- data/logplex.gemspec +2 -2
- data/spec/logplex/publisher_spec.rb +26 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffe48a52e4f1d01b38a9fec2cfd6cba64b4e735c926616d36b3a87b2ec6a75b1
|
4
|
+
data.tar.gz: c01b8e0627ae7410b4148ffcdc3ead41983df81fc161fdd1692456cd55573310
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e429707324d1c2e057dbc3a1d9880e9449e7f8088058953568cffa2e14b4cc4204c292e07a015d6c84099b391075a6236bf521b9a931c2b0d283b8a106f79a
|
7
|
+
data.tar.gz: 247a921c9096a10eda1df39b950eab655bb795438da89b650548f113d46ae206cd0bfe9786a4e07f4b31d4c65c1c5f012e12edd023b04306f3814fb613adb040
|
data/lib/logplex/publisher.rb
CHANGED
@@ -19,12 +19,12 @@ module Logplex
|
|
19
19
|
unless messages.is_a? Array
|
20
20
|
message_list = [message_list]
|
21
21
|
end
|
22
|
-
message_list.map! { |m| Message.new(m,
|
22
|
+
message_list.map! { |m| Message.new(m, { app_name: @token }.merge(opts)) }
|
23
23
|
message_list.each(&:validate)
|
24
24
|
if message_list.inject(true) { |accum, m| m.valid? }
|
25
25
|
begin
|
26
26
|
Timeout.timeout(Logplex.configuration.publish_timeout) do
|
27
|
-
api_post(message_list.map(&:syslog_frame).join(''))
|
27
|
+
api_post(message_list.map(&:syslog_frame).join(''), message_list.length)
|
28
28
|
true
|
29
29
|
end
|
30
30
|
rescue *PUBLISH_ERRORS
|
@@ -35,10 +35,11 @@ module Logplex
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
def api_post(message)
|
38
|
+
def api_post(message, number_messages)
|
39
39
|
Excon.post(@logplex_url, body: message, headers: {
|
40
40
|
"Content-Type" => 'application/logplex-1',
|
41
41
|
"Content-Length" => message.length,
|
42
|
+
"Logplex-Msg-Count" => number_messages
|
42
43
|
}, expects: [200, 204])
|
43
44
|
end
|
44
45
|
end
|
data/lib/logplex/version.rb
CHANGED
data/logplex.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'logplex/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "logplex"
|
8
8
|
gem.version = Logplex::VERSION
|
9
|
-
gem.authors = ["Harold Giménez"]
|
9
|
+
gem.authors = ["Harold Giménez", "Heroku"]
|
10
10
|
gem.email = ["harold.gimenez@gmail.com"]
|
11
11
|
gem.description = "Publish and Consume Logplex messages"
|
12
12
|
gem.summary = "Publish and Consume Logplex messages"
|
13
|
-
gem.homepage = "https://
|
13
|
+
gem.homepage = "https://github.com/heroku/logplex-gem"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'logplex/publisher'
|
3
|
+
require 'logplex/message'
|
3
4
|
|
4
5
|
describe Logplex::Publisher do
|
5
6
|
describe '#publish' do
|
@@ -28,13 +29,24 @@ describe Logplex::Publisher do
|
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'sends many messages in one request when passed an array' do
|
31
|
-
Excon.stub({ method: :post, password: "t.some-token", body: /here is another/ }, status: 204)
|
32
|
-
expect(Excon).to receive(:post).once
|
32
|
+
Excon.stub({ method: :post, password: "t.some-token", body: /message for you.+here is another.+some final thoughts/ }, status: 204)
|
33
33
|
messages = ['I have a message for you', 'here is another', 'some final thoughts']
|
34
|
+
publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
|
35
|
+
publisher.publish(messages)
|
36
|
+
end
|
34
37
|
|
38
|
+
it 'uses the token if app_name is not given' do
|
39
|
+
Excon.stub({ method: :post, password: "t.some-token", body: /t.some-token/ }, status: 204)
|
40
|
+
message = 'I have a message for you'
|
35
41
|
publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
|
42
|
+
publisher.publish(message)
|
43
|
+
end
|
36
44
|
|
37
|
-
|
45
|
+
it 'uses the given app_name' do
|
46
|
+
Excon.stub({ method: :post, password: "t.some-token", body: /foo/ }, status: 204)
|
47
|
+
message = 'I have a message for you'
|
48
|
+
publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
|
49
|
+
publisher.publish(message, app_name: 'foo')
|
38
50
|
end
|
39
51
|
|
40
52
|
it 'does the thing' do
|
@@ -72,5 +84,16 @@ describe Logplex::Publisher do
|
|
72
84
|
publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
|
73
85
|
expect(publisher.publish('hi')).to be_falsey
|
74
86
|
end
|
87
|
+
|
88
|
+
it "includes the correct headers" do
|
89
|
+
message = 'hello-harold'
|
90
|
+
headers = {
|
91
|
+
"Content-Type" => 'application/logplex-1',
|
92
|
+
"Content-Length" => 79,
|
93
|
+
"Logplex-Msg-Count" => 1
|
94
|
+
}
|
95
|
+
expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
|
96
|
+
Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
|
97
|
+
end
|
75
98
|
end
|
76
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logplex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harold Giménez
|
8
|
+
- Heroku
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: valcro
|
@@ -77,7 +78,7 @@ files:
|
|
77
78
|
- spec/logplex/message_spec.rb
|
78
79
|
- spec/logplex/publisher_spec.rb
|
79
80
|
- spec/spec_helper.rb
|
80
|
-
homepage: https://
|
81
|
+
homepage: https://github.com/heroku/logplex-gem
|
81
82
|
licenses: []
|
82
83
|
metadata: {}
|
83
84
|
post_install_message:
|
@@ -95,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.4.5.1
|
99
|
+
rubygems_version: 3.0.3
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Publish and Consume Logplex messages
|
@@ -105,4 +105,3 @@ test_files:
|
|
105
105
|
- spec/logplex/message_spec.rb
|
106
106
|
- spec/logplex/publisher_spec.rb
|
107
107
|
- spec/spec_helper.rb
|
108
|
-
has_rdoc:
|