graylog2_exceptions 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +4 -0
- data/Rakefile +11 -0
- data/graylog2_exceptions.gemspec +33 -0
- data/lib/graylog2_exceptions.rb +46 -0
- metadata +87 -0
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('graylog2_exceptions', '0.5.1') do |p|
|
6
|
+
p.description = "A Rack middleware that sends every Exception as GELF message to your Graylog2 server"
|
7
|
+
p.url = 'http://www.graylog2.org/'
|
8
|
+
p.author = 'Lennart Koopmann'
|
9
|
+
p.email = 'lennart@socketfeed.com'
|
10
|
+
p.runtime_dependencies = ["gelf"]
|
11
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{graylog2_exceptions}
|
5
|
+
s.version = "0.5.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Lennart Koopmann"]
|
9
|
+
s.date = %q{2010-10-08}
|
10
|
+
s.description = %q{A Rack middleware that sends every Exception as GELF message to your Graylog2 server}
|
11
|
+
s.email = %q{lennart@socketfeed.com}
|
12
|
+
s.extra_rdoc_files = ["lib/graylog2_exceptions.rb"]
|
13
|
+
s.files = ["Manifest", "Rakefile", "graylog2_exceptions.gemspec", "lib/graylog2_exceptions.rb"]
|
14
|
+
s.homepage = %q{http://www.graylog2.org/}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Graylog2_exceptions"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{graylog2_exceptions}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{A Rack middleware that sends every Exception as GELF message to your Graylog2 server}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<gelf>, [">= 0"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<gelf>, [">= 0"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<gelf>, [">= 0"])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gelf'
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
class Graylog2Exceptions
|
6
|
+
def initialize(app, options)
|
7
|
+
@gl2_hostname = options[:host] || "localhost"
|
8
|
+
@gl2_port = options[:port] || 12201
|
9
|
+
@local_app_name = options[:local_app_name] || Socket::gethostname
|
10
|
+
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
# Make thread safe
|
16
|
+
dup._call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
def _call(env)
|
20
|
+
begin
|
21
|
+
# Call the app we are monitoring
|
22
|
+
@app.call(env)
|
23
|
+
rescue StandardError, SyntaxError, LoadError => err
|
24
|
+
# An exception has been raised. Send to Graylog2!
|
25
|
+
send_to_graylog2(err)
|
26
|
+
|
27
|
+
# Raise the exception again to pass back to app.
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def send_to_graylog2 err
|
33
|
+
begin
|
34
|
+
gelf = Graylog2::Gelf.new @gl2_hostname, @gl2_port
|
35
|
+
gelf.short_message = err.message
|
36
|
+
gelf.full_message = err.backtrace.join("\n")
|
37
|
+
gelf.level = @level
|
38
|
+
gelf.host = @local_app_name
|
39
|
+
gelf.file = err.backtrace[0].split(":")[0]
|
40
|
+
gelf.line = err.backtrace[0].split(":")[1]
|
41
|
+
gelf.send
|
42
|
+
rescue => i_err
|
43
|
+
puts "Graylog2 Exception logger. Could not send message: " + i_err.message
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: graylog2_exceptions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Lennart Koopmann
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-08 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: gelf
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: A Rack middleware that sends every Exception as GELF message to your Graylog2 server
|
36
|
+
email: lennart@socketfeed.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- lib/graylog2_exceptions.rb
|
43
|
+
files:
|
44
|
+
- Manifest
|
45
|
+
- Rakefile
|
46
|
+
- graylog2_exceptions.gemspec
|
47
|
+
- lib/graylog2_exceptions.rb
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://www.graylog2.org/
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --line-numbers
|
55
|
+
- --inline-source
|
56
|
+
- --title
|
57
|
+
- Graylog2_exceptions
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 11
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 2
|
78
|
+
version: "1.2"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project: graylog2_exceptions
|
82
|
+
rubygems_version: 1.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: A Rack middleware that sends every Exception as GELF message to your Graylog2 server
|
86
|
+
test_files: []
|
87
|
+
|