rack-logstash 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c1754225ede7a3f169dbd9df3f2c4c3e91ee014
4
- data.tar.gz: 54b08203e18a32428929e01dc0093fb63cbdd00d
3
+ metadata.gz: 579f583ac3d77ba36605fde8016cf8b35148fb31
4
+ data.tar.gz: 3e7a7de816ad49987918b1cb0fd8b02b5e4eb7b3
5
5
  SHA512:
6
- metadata.gz: 569bdaf5fc7e02735ee6549388af45cadb0e1403f05f7af12223926065148bef741bde60de85ca3f59b30b98ffccc22a5f2e38c457a9e5c5b3dfaa784bf4b1fc
7
- data.tar.gz: e83ea0a8bcb28dfca1ff4ceeaed27d2a24d797cef847ca55303a3b2dcc1da52d22d42ca9e2ab0b751475c3ad221db9f18f3c80a2958fffdd4cf7624b2baa6e32
6
+ metadata.gz: 7358100741f327cc2af288006710045f5ab47ddd57ab25dffe74de335ae9b495f66afa4b8ef4faed41d635c898027bc49203ab043f8c312929d03fb11cc21a28
7
+ data.tar.gz: 17d7186d1ceec4b0da71149ce5422a59e04e7cc1c732cd79aa82d660be279ec19508972b68ab6c208d26d9e743cf1fe0029ed5d8e07c28520c63157a06d389dc
data/lib/rack/logstash.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'json'
2
1
  require 'rack/logstash/extended_request'
3
2
  require 'rack/logstash/transport'
4
3
  require 'ipaddr'
@@ -33,7 +32,7 @@ module Rack
33
32
  private
34
33
 
35
34
  def log_request(env, response)
36
- @server.send(request_log_entry(env, response).to_json)
35
+ @server.send(request_log_entry(env, response))
37
36
  end
38
37
 
39
38
  def request_log_entry(env, response)
@@ -64,7 +63,7 @@ module Rack
64
63
  end
65
64
 
66
65
  def log_exception(env, ex)
67
- @server.send(exception_log_entry(env, ex).to_json)
66
+ @server.send(exception_log_entry(env, ex))
68
67
  end
69
68
 
70
69
  def exception_log_entry(env, ex)
@@ -1,6 +1,7 @@
1
1
  require 'socket'
2
2
  require 'thread'
3
3
  require 'uri'
4
+ require 'json'
4
5
 
5
6
  module Rack
6
7
  class Logstash
@@ -12,10 +13,14 @@ module Rack
12
13
  @sender = sender_thread
13
14
  end
14
15
 
15
- def send(s)
16
+ def send(msg)
16
17
  begin
17
- @blmutex.synchronize { @backlog << s }
18
+ @blmutex.synchronize { @backlog << msg.to_json }
18
19
  @sender.run
20
+ rescue EncodingError, JSON::JSONError => ex
21
+ $stderr.puts "Serialisation error: #{ex.message} (#{ex.class})"
22
+ $stderr.puts "Message: #{msg.inspect}"
23
+ $stderr.puts ex.backtrace.map { |l| " #{l}" }
19
24
  rescue StandardError => ex
20
25
  $stderr.puts "Failed to send message: #{ex.message} (#{ex.class})"
21
26
  $stderr.puts ex.backtrace.map { |l| " #{l}" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-logstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler