syslogstash 0.1.3 → 0.1.4

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: 1d3e431ae7c66eafbe07686b87f012d63bc563e1
4
- data.tar.gz: 29156c243ffbc6c4b84aaa92105f2db286c239ca
3
+ metadata.gz: 57f9a03e8075654fe964cc2fd0da045912296789
4
+ data.tar.gz: 2e6e1b3264305e47a55d5fd9b275527e4e7b57dc
5
5
  SHA512:
6
- metadata.gz: 51a912d37ea4eb14891eb6256bc6d0465e0eab7afd53e057951fc83cedcc8be39b35b22c1f97492cae32ad5f320d36a89c8ae9017faa4abacdfcf2c83a412aa0
7
- data.tar.gz: a3d81b2f2195f005f2665fb470f644f38360713ce51f8ac163c0f826d5d598d39539643e6df919dcef575f0b28298afcb89e00a784d309ab0d31a4ee77741390
6
+ metadata.gz: 7be74a42eb0f2970cf47872c0d83a2a52fe5ab8d1e739e1951759ec70ce8bf6f5987fb47915691fa172c67f2fd2a5ab93099afe66d62264434a37f9102bad080
7
+ data.tar.gz: be5027ec85b4e32364a5a5f0101160b41634d76691c0271730f1599b83de6291d1ad747413613a1c2a6ad996865f3fa0f176cd22c1064c09e7788117bc4a9d97
@@ -56,6 +56,9 @@ class Syslogstash::LogstashWriter
56
56
  # If we got here, we sent successfully, so we don't want
57
57
  # to put the entry back on the queue in the ensure block
58
58
  entry = nil
59
+ rescue StandardError => ex
60
+ $stderr.puts "Unhandled exception: #{ex.message} (#{ex.class})"
61
+ $stderr.puts ex.backtrace.map { |l| " #{l}" }.join("\n")
59
62
  ensure
60
63
  @entries_mutex.synchronize { @entries.unshift if entry }
61
64
  end
@@ -19,8 +19,9 @@ class Syslogstash::SyslogReader
19
19
  begin
20
20
  socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0)
21
21
  socket.bind(Socket.pack_sockaddr_un(@file))
22
- rescue Errno::EEXIST
23
- File.unlink(@file)
22
+ rescue Errno::EEXIST, Errno::EADDRINUSE
23
+ log { "socket file #{@file} already exists; deleting"
24
+ File.unlink(@file) rescue nil
24
25
  retry
25
26
  rescue SystemCallError
26
27
  $stderr.puts "Error while trying to bind to #{@file}"
@@ -36,6 +37,7 @@ class Syslogstash::SyslogReader
36
37
  end
37
38
  ensure
38
39
  socket.close
40
+ log { "removing socket file #{@file}"
39
41
  File.unlink(@file) rescue nil
40
42
  end
41
43
  end
@@ -74,7 +76,7 @@ class Syslogstash::SyslogReader
74
76
  facility: facility,
75
77
  hostname: hostname,
76
78
  program: program,
77
- pid: pid,
79
+ pid: pid.nil? ? nil : pid.to_i,
78
80
  message: message,
79
81
  ).to_json
80
82
 
@@ -89,13 +91,11 @@ class Syslogstash::SyslogReader
89
91
  e['@version'] = '1'
90
92
  e['@timestamp'] = Time.now.utc.strftime("%FT%T.%LZ")
91
93
 
92
- h['facility_name'] = FACILITIES[h[:facility]]
93
- h['severity_name'] = SEVERITIES[h[:severity]]
94
+ h[:facility_name] = FACILITIES[h[:facility]]
95
+ h[:severity_name] = SEVERITIES[h[:severity]]
94
96
 
95
97
  e.merge!(h.delete_if { |k,v| v.nil? })
96
98
 
97
- e[:pid] = e[:pid].to_i if e.has_key?(:pid)
98
-
99
99
  e.merge!(@tags) if @tags.is_a? Hash
100
100
 
101
101
  debug { "Log entry is: #{e.inspect}" }
@@ -18,6 +18,10 @@ module Syslogstash::Worker
18
18
 
19
19
  private
20
20
 
21
+ def log
22
+ puts "#{Time.now.strftime("%F %T.%L")} #{self.class} #{yield.to_s}"
23
+ end
24
+
21
25
  def debug
22
26
  if ENV['DEBUG_SYSLOGSTASH']
23
27
  puts "#{Time.now.strftime("%F %T.%L")} #{self.class} #{yield.to_s}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syslogstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler