semlogr-sinks-logentries 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de487f4a0cdf47bfeb2f3bf452abed62af3e0d43
4
- data.tar.gz: ed24d69bb994a3d0a7dfe1f534e3092586d2c188
3
+ metadata.gz: 8b1ed2397e64273d4e45d65512d70e9cd5586635
4
+ data.tar.gz: 0b65ba8e1e4da900d2d34551c1c4ce29731df4b7
5
5
  SHA512:
6
- metadata.gz: 8200e5dd95ebe42a2b52a6b0b430a70cae12a873a105603faaedf69c601ded03560732512d45774dc13b09415c5a96aad0c979ffde162c46d63da57753767a60
7
- data.tar.gz: c73abc2f1ecbcff7b41970f9dfddc3b1c7cb5e81e1462e1a04313f136c978a871f8a1671c5f09c487b8e549c6ce086c627e2b7229e2573a6bcc4fb8e6ccacd0d
6
+ metadata.gz: f78795eab37e1cc837cb6fdaace71b29e148ac3315decd90677c4a47023aa14a667d3dd70faae77ae14cb1cb15f0f68c6d3eb2e86a0fbf2bbe815a27507c9a2a
7
+ data.tar.gz: dc9c1ca3d503ff6280d25cbefa47185302b62ef1fe095257fa47e7b64f40776db8476b0f0c35b096a6336b4e48e5b3ca359c41a33dd8d47e10bfe721884a4098
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.2.2
4
+
5
+ - Add automatic flushing of buffer when application exits
6
+
3
7
  ### 0.2.1
4
8
 
5
9
  - Use new semlogr component registry
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Semlogr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -40,12 +40,6 @@ Semlogr.info('Customer {customer_id} did something interesting', customer_id: 12
40
40
 
41
41
  After cloning the repository run `bundle install` to get up and running, to run the specs just run `rake spec`.
42
42
 
43
- ## Changes
44
-
45
- ### 0.1.0
46
-
47
- - Initial commit.
48
-
49
43
  ## Contributing
50
44
 
51
45
  See anything broken or something you would like to improve? feel free to submit an issue or better yet a pull request!
@@ -1,5 +1,6 @@
1
1
  require 'stud/buffer'
2
2
  require 'socket'
3
+ require 'timeout'
3
4
  require 'openssl'
4
5
  require 'semlogr/formatters/json_formatter'
5
6
  require 'semlogr/sinks/logentries/tcp_connection'
@@ -10,12 +11,14 @@ module Semlogr
10
11
  class Sink
11
12
  include Stud::Buffer
12
13
 
13
- def initialize(token, opts = {})
14
+ def initialize(token, formatter: nil, **opts)
15
+ opts = default_opts.merge(opts)
16
+
14
17
  @token = token
15
- @options = opts
16
- @formatter = opts.fetch(:formatter, Formatters::JsonFormatter.new)
18
+ @formatter = formatter || Formatters::JsonFormatter.new
17
19
  @connection = create_connection(opts)
18
20
 
21
+ exit_handler_initialize(opts)
19
22
  buffer_initialize(opts)
20
23
  end
21
24
 
@@ -32,6 +35,26 @@ module Semlogr
32
35
 
33
36
  private
34
37
 
38
+ def default_opts
39
+ {
40
+ flush_at_exit: true,
41
+ flush_at_exit_timeout: 10
42
+ }
43
+ end
44
+
45
+ def exit_handler_initialize(opts)
46
+ return unless opts[:flush_at_exit]
47
+
48
+ at_exit do
49
+ flush_timeout = opts[:flush_at_exit_timeout]
50
+ Timeout.timeout(flush_timeout) do
51
+ buffer_flush(final: true)
52
+
53
+ @connection.close
54
+ end
55
+ end
56
+ end
57
+
35
58
  def create_connection(opts)
36
59
  host = opts.fetch(:host, 'data.logentries.com')
37
60
  ssl = opts.fetch(:ssl, true)
@@ -21,7 +21,7 @@ module Semlogr
21
21
  connect unless connected?
22
22
 
23
23
  @socket.write(data)
24
- rescue
24
+ rescue StandardError
25
25
  close
26
26
 
27
27
  raise
@@ -1,7 +1,7 @@
1
1
  module Semlogr
2
2
  module Sinks
3
3
  module Logentries
4
- VERSION = '0.2.1'.freeze
4
+ VERSION = '0.2.2'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
5
4
  require 'semlogr/sinks/logentries/version'
6
5
 
7
6
  Gem::Specification.new do |spec|
@@ -23,8 +22,8 @@ Gem::Specification.new do |spec|
23
22
  spec.add_dependency 'stud', '~> 0.0.10'
24
23
 
25
24
  spec.add_development_dependency 'bundler', '~> 1.13'
26
- spec.add_development_dependency 'pry', '~> 0.10.3'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec', '~> 3.0'
29
- spec.add_development_dependency 'rubocop', '~> 0.49.1'
25
+ spec.add_development_dependency 'pry', '~> 0.11'
26
+ spec.add_development_dependency 'rake', '~> 12.3'
27
+ spec.add_development_dependency 'rspec', '~> 3.7'
28
+ spec.add_development_dependency 'rubocop', '~> 0.53'
30
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semlogr-sinks-logentries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Sedich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semlogr
@@ -58,56 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.3
61
+ version: '0.11'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.3
68
+ version: '0.11'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '12.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '12.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '3.7'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
96
+ version: '3.7'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.49.1
103
+ version: '0.53'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.49.1
110
+ version: '0.53'
111
111
  description: A semlogr sink for logging to logentries.
112
112
  email:
113
113
  - stefan.sedich@gmail.com
@@ -121,6 +121,7 @@ files:
121
121
  - ".travis.yml"
122
122
  - CHANGELOG.md
123
123
  - Gemfile
124
+ - LICENSE.md
124
125
  - README.md
125
126
  - Rakefile
126
127
  - bin/console