abrt 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +27 -1
- data/lib/abrt.rb +4 -1
- data/lib/abrt/exception.rb +5 -3
- data/lib/abrt/handler.rb +44 -41
- metadata +33 -50
data/README.rdoc
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
= abrt
|
2
2
|
|
3
|
-
|
3
|
+
Provides ABRT reporting support for libraries/applications written using Ruby.
|
4
|
+
|
5
|
+
Please note that ABRT will be able to report errors only for applications which are already RPM packaged. Errors in other applications are ignored.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
<tt>
|
10
|
+
$ gem install abrt
|
11
|
+
</tt>
|
12
|
+
|
13
|
+
or if you're using Bundler, put
|
14
|
+
|
15
|
+
<tt>
|
16
|
+
gem "mocha", :require => false
|
17
|
+
</tt>
|
18
|
+
|
19
|
+
line into your <em>Gemfile</em>.
|
20
|
+
|
21
|
+
== Usage
|
22
|
+
|
23
|
+
There are several ways how to run any application with ABRT handler enabled.
|
24
|
+
|
25
|
+
1. Use <tt>require 'abrt'</tt> at the beginning of your application.
|
26
|
+
2. If you can't modify the application and you still want to use ABRT support, then you need to define <tt>RUBYOPT="-rabrt"</tt> environment variable. This will ensure that ABRT support gets loaded and the exception handler hooks are installed.
|
27
|
+
3. If you want to ensure, that ABRT handler is always used, add <tt>RUBYOPT="-rabrt"</tt> into your <em>.bashrc</em> file. This will ensure, that Ruby loads ABRT handler every time its starts.
|
28
|
+
|
29
|
+
Now, everytime the unhandled exception is captured, ABRT handler prepares bugreport, which can be submitted into http://bugzilla.redhat.com component later using standard ABRT tools.
|
4
30
|
|
5
31
|
== Contributing to abrt
|
6
32
|
|
data/lib/abrt.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
at_exit do
|
2
|
-
|
2
|
+
# Do not report every exception:
|
3
|
+
# SystemExit - raised by Kernel#exit call
|
4
|
+
# Interrupt - typically issued because the user pressed Ctrl+C
|
5
|
+
if $! and ![SystemExit, Interrupt].include?($!.class)
|
3
6
|
require 'abrt/handler'
|
4
7
|
ABRT.handle_exception($!)
|
5
8
|
end
|
data/lib/abrt/exception.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# This might be removed if http://bugs.ruby-lang.org/issues/6286 gets accepted.
|
2
|
+
|
1
3
|
module ABRT
|
2
4
|
module Exception
|
3
5
|
def format
|
4
|
-
backtrace = self.backtrace.
|
5
|
-
backtrace[0]
|
6
|
-
backtrace
|
6
|
+
backtrace = self.backtrace.collect { |line| "\tfrom #{line}" }
|
7
|
+
backtrace[0] = "#{self.backtrace.first}: #{self.message} (#{self.class.name})"
|
8
|
+
backtrace
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/abrt/handler.rb
CHANGED
@@ -1,65 +1,68 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'syslog'
|
3
|
+
require 'abrt/exception.rb'
|
4
|
+
|
1
5
|
module ABRT
|
2
6
|
|
3
7
|
def self.handle_exception(exception)
|
4
|
-
last_exception = $!
|
5
|
-
|
6
8
|
syslog.notice "detected unhandled Ruby exception in '#{$0}'"
|
7
9
|
|
8
|
-
|
9
|
-
last_exception.extend(ABRT::Exception)
|
10
|
+
exception.extend(ABRT::Exception)
|
10
11
|
|
11
12
|
# TODO: Report only scripts with absolute path.
|
12
13
|
|
13
|
-
write_dump
|
14
|
+
write_dump exception.format
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def self.syslog
|
19
|
-
|
20
|
-
|
21
|
-
require 'syslog'
|
22
|
-
@syslog = Syslog.open 'abrt'
|
20
|
+
@syslog ||= Syslog.open 'abrt'
|
23
21
|
end
|
24
22
|
|
25
|
-
def self.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# TODO: Do we need specialized Ruby analyzer?
|
37
|
-
# socket.write "ANALYZER=Ruby\0"
|
38
|
-
socket.write "ANALYZER=Python\0"
|
39
|
-
socket.write "BASENAME=rbhook\0"
|
40
|
-
socket.write "REASON=#{backtrace.first}\0"
|
41
|
-
socket.write "BACKTRACE=#{backtrace}\0"
|
42
|
-
socket.close_write
|
23
|
+
def self.report(backtrace, io = abrt_socket)
|
24
|
+
io.write "PUT / HTTP/1.1\r\n\r\n"
|
25
|
+
io.write "PID=#{Process.pid}\0"
|
26
|
+
io.write "EXECUTABLE=#{$PROGRAM_NAME}\0"
|
27
|
+
# TODO: Do we need specialized Ruby analyzer?
|
28
|
+
# io.write "ANALYZER=Ruby\0"
|
29
|
+
io.write "ANALYZER=Python\0"
|
30
|
+
io.write "BASENAME=rbhook\0"
|
31
|
+
io.write "REASON=#{backtrace.first}\0"
|
32
|
+
io.write "BACKTRACE=#{backtrace.join("\n")}\0"
|
33
|
+
io.close_write
|
43
34
|
|
44
|
-
|
35
|
+
yield io.read
|
45
36
|
|
46
|
-
|
37
|
+
io.close
|
38
|
+
rescue StandardError => e
|
39
|
+
syslog.err "can't communicate with ABRT daemon, is it running? #{e.message}"
|
40
|
+
end
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
if
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
if
|
56
|
-
|
57
|
-
|
42
|
+
def self.write_dump(backtrace)
|
43
|
+
report backtrace do |response|
|
44
|
+
if response.empty?
|
45
|
+
syslog.err "error sending data to ABRT daemon. Empty response received"
|
46
|
+
else
|
47
|
+
parts = response.split
|
48
|
+
code = Integer(parts[1]) rescue false
|
49
|
+
if (parts.size < 2) or
|
50
|
+
(not parts[0] =~ %r{^HTTP/}) or
|
51
|
+
(not code) or
|
52
|
+
(code >= 400)
|
53
|
+
then
|
58
54
|
syslog.err "error sending data to ABRT daemon: #{response}"
|
59
55
|
end
|
60
56
|
end
|
61
|
-
rescue StandardError => e
|
62
|
-
syslog.err "can't communicate with ABRT daemon, is it running? #{e.message}"
|
63
57
|
end
|
64
58
|
end
|
59
|
+
|
60
|
+
# TODO: Get VAR_RUN from ABRT configuration.
|
61
|
+
VAR_RUN = '/var/run'
|
62
|
+
ABRT_SOCKET_PATH = File.join VAR_RUN, 'abrt/abrt.socket'
|
63
|
+
|
64
|
+
def self.abrt_socket
|
65
|
+
UNIXSocket.new ABRT_SOCKET_PATH
|
66
|
+
end
|
67
|
+
|
65
68
|
end
|
metadata
CHANGED
@@ -1,48 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: abrt
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Vít Ondruch
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 47
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 8
|
32
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 2.8.0
|
34
22
|
type: :development
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.8.0
|
36
30
|
description: Provides ABRT reporting support for applications written using Ruby.
|
37
31
|
email: v.ondruch@tiscali.cz
|
38
32
|
executables: []
|
39
|
-
|
40
33
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
43
35
|
- LICENSE.txt
|
44
36
|
- README.rdoc
|
45
|
-
files:
|
37
|
+
files:
|
46
38
|
- LICENSE.txt
|
47
39
|
- README.rdoc
|
48
40
|
- Rakefile
|
@@ -50,37 +42,28 @@ files:
|
|
50
42
|
- lib/abrt/handler.rb
|
51
43
|
- lib/abrt.rb
|
52
44
|
homepage: http://github.com/voxik/abrt-ruby
|
53
|
-
licenses:
|
45
|
+
licenses:
|
54
46
|
- MIT
|
55
47
|
post_install_message:
|
56
48
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
49
|
+
require_paths:
|
59
50
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
52
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
- 0
|
68
|
-
version: "0"
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
58
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
78
63
|
requirements: []
|
79
|
-
|
80
64
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.8.
|
65
|
+
rubygems_version: 1.8.24
|
82
66
|
signing_key:
|
83
67
|
specification_version: 3
|
84
68
|
summary: ABRT support for Ruby MRI.
|
85
69
|
test_files: []
|
86
|
-
|