logglier 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,20 +15,12 @@ module Logglier
15
15
  # @option [String] ca_file Path to the ca file
16
16
  def initialize(input_uri, opts={})
17
17
  @input_uri = input_uri
18
+ @verify_mode = opts[:verify_mode] || OpenSSL::SSL::VERIFY_PEER
19
+ @ca_file = opts[:ca_file]
20
+ @read_timeout = opts[:read_timeout] || 5
21
+ @open_timeout = opts[:open_timeout] || 5
18
22
 
19
- @http = Net::HTTP.new(@input_uri.host, @input_uri.port)
20
-
21
- if @input_uri.scheme == 'https'
22
- @http.use_ssl = true
23
- @http.verify_mode = opts[:verify_mode] || OpenSSL::SSL::VERIFY_PEER
24
- @http.ca_file = opts[:ca_file] if opts[:ca_file]
25
- end
26
-
27
- # We prefer persistent HTTP connections, so workaround http://redmine.ruby-lang.org/issues/4522
28
- @http.start
29
-
30
- @http.read_timeout = opts[:read_timeout] || 2
31
- @http.open_timeout = opts[:open_timeout] || 2
23
+ connect!
32
24
  end
33
25
 
34
26
  # Delivers the message via HTTP, handling errors
@@ -43,6 +35,7 @@ module Logglier
43
35
  rescue Errno::ECONNRESET
44
36
  unless retried
45
37
  retried = true
38
+ connect!
46
39
  retry
47
40
  else
48
41
  $stderr.puts "WARNING: connection was reset while posting message: #{message}"
@@ -51,6 +44,26 @@ module Logglier
51
44
  $stderr.puts "WARNING: #{e.class} posting message: #{message}"
52
45
  end
53
46
  end
47
+
48
+ private
49
+
50
+ def connect!
51
+ @http = Net::HTTP.new(@input_uri.host, @input_uri.port)
52
+
53
+ if @input_uri.scheme == 'https'
54
+ @http.use_ssl = true
55
+ @http.verify_mode = @verify_mode
56
+ @http.ca_file = @ca_file
57
+ end
58
+
59
+ # We prefer persistent HTTP connections, so workaround http://redmine.ruby-lang.org/issues/4522
60
+ # This causes problems with 1.8.6, so don't do it there.
61
+ @http.start unless RUBY_VERSION == "1.8.6"
62
+
63
+ @http.read_timeout = @read_timeout
64
+ @http.open_timeout = @open_timeout
65
+
66
+ end
54
67
  end
55
68
 
56
69
  end
@@ -1,3 +1,3 @@
1
1
  module Logglier
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logglier
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 29
4
5
  prerelease:
5
- version: 0.2.4
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 5
10
+ version: 0.2.5
6
11
  platform: ruby
7
12
  authors:
8
13
  - Edward Muller (aka freeformz)
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-07-06 00:00:00 -07:00
18
+ date: 2011-07-08 00:00:00 -07:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,9 @@ dependencies:
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
24
32
  version: "0"
25
33
  type: :development
26
34
  version_requirements: *id001
@@ -32,6 +40,11 @@ dependencies:
32
40
  requirements:
33
41
  - - ~>
34
42
  - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 2
46
+ - 5
47
+ - 0
35
48
  version: 2.5.0
36
49
  type: :development
37
50
  version_requirements: *id002
@@ -75,12 +88,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
88
  requirements:
76
89
  - - ">="
77
90
  - !ruby/object:Gem::Version
91
+ hash: 59
92
+ segments:
93
+ - 1
94
+ - 8
95
+ - 6
78
96
  version: 1.8.6
79
97
  required_rubygems_version: !ruby/object:Gem::Requirement
80
98
  none: false
81
99
  requirements:
82
100
  - - ">="
83
101
  - !ruby/object:Gem::Version
102
+ hash: 23
103
+ segments:
104
+ - 1
105
+ - 3
106
+ - 6
84
107
  version: 1.3.6
85
108
  requirements: []
86
109