padrino_gelflogger 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -0
- data/lib/padrino_gelflogger/gelf_exception_logger.rb +25 -0
- data/lib/padrino_gelflogger/version.rb +1 -1
- data/lib/padrino_gelflogger.rb +1 -0
- metadata +17 -16
data/README.md
CHANGED
@@ -29,6 +29,13 @@ You can manually log performance stats using `logger.bench`, for example:
|
|
29
29
|
|
30
30
|
bench("action", Time.local(2012, 12, 20, 20, 12, 00), "message", level=:debug, color=:yellow, full_message="more info about this run")
|
31
31
|
|
32
|
+
## GelfExceptionLogger
|
33
|
+
In order to log exceptions to [Graylog](http://graylog2.org/) add this to your app.rb:
|
34
|
+
|
35
|
+
register Padrino::GelfExceptionLogger
|
36
|
+
|
37
|
+
For this to work, you __must__ set the Padrino.logger to the Padrino::GelfLogger first!
|
38
|
+
|
32
39
|
|
33
40
|
More information about the parameters can be found at in the [http://rubydoc.info/github/Graylog2/gelf-rb/master/GELF/Notifier](Graylog2) gem docs.
|
34
41
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Padrino
|
2
|
+
module GelfExceptionLogger
|
3
|
+
|
4
|
+
def self.registered(app)
|
5
|
+
app.set :dump_errors, false # rack crashes when true :(
|
6
|
+
app.error 500 do
|
7
|
+
raise "Pardino.logger must be set to Padrino::GelfLogger" unless logger.respond_to? :notify!
|
8
|
+
err = env['sinatra.error']
|
9
|
+
short_message = "#{err.class} - #{err.message}"
|
10
|
+
full_message = err.backtrace[0..2].join("\n ")
|
11
|
+
full_message += "\n\n---Params:\n"
|
12
|
+
params.each { |k,v| full_message += "\n#{k.inspect} => #{v.inspect}" }
|
13
|
+
|
14
|
+
logger.notify({
|
15
|
+
:short_message => short_message,
|
16
|
+
:full_message => full_message[0..2000], # there is a bug in GELF (1.32), chunking is not working :()
|
17
|
+
:level => GELF::Levels::FATAL
|
18
|
+
})
|
19
|
+
|
20
|
+
raise
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/padrino_gelflogger.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino_gelflogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gelf
|
16
|
-
requirement: &
|
16
|
+
requirement: &70274629952540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70274629952540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &70274629951400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.10.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70274629951400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest-reporters
|
38
|
-
requirement: &
|
38
|
+
requirement: &70274629944000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70274629944000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rr
|
49
|
-
requirement: &
|
49
|
+
requirement: &70274629942800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70274629942800
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: timecop
|
60
|
-
requirement: &
|
60
|
+
requirement: &70274629942100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70274629942100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &70274629941180 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70274629941180
|
80
80
|
description: Log from Padrino to Graylog2
|
81
81
|
email:
|
82
82
|
- pz@anixe.pl
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
93
|
- lib/padrino_gelflogger.rb
|
94
|
+
- lib/padrino_gelflogger/gelf_exception_logger.rb
|
94
95
|
- lib/padrino_gelflogger/gelf_logger.rb
|
95
96
|
- lib/padrino_gelflogger/version.rb
|
96
97
|
- padrino_gelflogger.gemspec
|
@@ -110,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
segments:
|
112
113
|
- 0
|
113
|
-
hash:
|
114
|
+
hash: 455111441048492565
|
114
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
none: false
|
116
117
|
requirements:
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
segments:
|
121
122
|
- 0
|
122
|
-
hash:
|
123
|
+
hash: 455111441048492565
|
123
124
|
requirements: []
|
124
125
|
rubyforge_project:
|
125
126
|
rubygems_version: 1.8.6
|