slowgrowl 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/slowgrowl.rb +48 -38
- data/slowgrowl.gemspec +1 -1
- metadata +6 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/slowgrowl.rb
CHANGED
@@ -9,6 +9,7 @@ module SlowGrowl
|
|
9
9
|
config.slowgrowl = ActiveSupport::OrderedOptions.new
|
10
10
|
config.slowgrowl.warn = 1000 # default slow alert set to 1000ms
|
11
11
|
config.slowgrowl.sticky = false # should error warnings be sticky?
|
12
|
+
config.slowgrowl.debug = false # print debug information
|
12
13
|
|
13
14
|
initializer "slowgrowl.initialize" do |app|
|
14
15
|
ActiveSupport::Notifications.subscribe do |*args|
|
@@ -28,51 +29,60 @@ module SlowGrowl
|
|
28
29
|
:error
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
begin
|
33
|
+
e = event.payload
|
34
|
+
message = case type
|
35
|
+
when 'action_controller' then
|
36
|
+
case action
|
37
|
+
when 'process_action' then
|
38
|
+
# {:controller=>"WidgetsController", :action=>"index", :params=>{"controller"=>"widgets", "action"=>"index"},
|
39
|
+
# :formats=>[:html], :method=>"GET", :path=>"/widgets", :status=>200, :view_runtime=>52.25706100463867,
|
40
|
+
# :db_runtime=>0}
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
if e[:exception]
|
43
|
+
"%s#%s.\n\n%s" % [
|
44
|
+
e[:controller], e[:action], e[:exception].join(', ')
|
45
|
+
]
|
46
|
+
else
|
47
|
+
"%s#%s (%s).\nDB: %.1f, View: %.1f" % [
|
48
|
+
e[:controller], e[:action], e[:status], e[:db_runtime], e[:view_runtime]
|
49
|
+
]
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
else
|
53
|
+
'%s#%s (%s)' % [e[:controller], e[:action], e[:status]]
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
when 'action_view' then
|
57
|
+
# {:identifier=>"text template", :layout=>nil }
|
58
|
+
'%s, layout: %s' % [e[:identifier], e[:layout].nil? ? 'none' : e[:layout]]
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
when 'active_record' then
|
61
|
+
# {:sql=>"SELECT "widgets".* FROM "widgets", :name=>"Widget Load", :connection_id=>2159415800}
|
62
|
+
"%s\n\n%s" % [e[:name], e[:sql].gsub("\n", ' ').squeeze(' ')]
|
63
|
+
else
|
64
|
+
'Duration: %.1f' % [event.duration] if event.respond_to? :duration
|
65
|
+
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
if alert
|
68
|
+
title = "%1.fms - %s : %s" % [event.duration, action.humanize, type.camelize]
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
case NOTIFIER
|
71
|
+
when :growl
|
72
|
+
if Growl.installed?
|
73
|
+
Growl.send("notify_#{alert}", message, {:title => title, :sticky => sticky})
|
74
|
+
end
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
+
when :libnotify
|
77
|
+
Notify::Notification.new(title, message, nil, nil).show
|
78
|
+
end
|
79
|
+
end
|
80
|
+
rescue Exception => e
|
81
|
+
if config.slowgrowl.debug
|
82
|
+
puts e
|
83
|
+
puts event.inspect
|
84
|
+
puts e.backtrace.join("\n")
|
85
|
+
puts "-- If you're seeing this, you should probably open a ticket on github :-)"
|
76
86
|
end
|
77
87
|
end
|
78
88
|
|
data/slowgrowl.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'lib/platform'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{slowgrowl}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ilya Grigorik", "Milan Dobrota"]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ilya Grigorik
|
@@ -22,6 +22,7 @@ dependencies:
|
|
22
22
|
name: growl
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
@@ -57,6 +58,7 @@ rdoc_options:
|
|
57
58
|
require_paths:
|
58
59
|
- lib
|
59
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
60
62
|
requirements:
|
61
63
|
- - ">="
|
62
64
|
- !ruby/object:Gem::Version
|
@@ -64,6 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
66
|
- 0
|
65
67
|
version: "0"
|
66
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
67
70
|
requirements:
|
68
71
|
- - ">="
|
69
72
|
- !ruby/object:Gem::Version
|
@@ -73,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
76
|
requirements: []
|
74
77
|
|
75
78
|
rubyforge_project: slowgrowl
|
76
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.7
|
77
80
|
signing_key:
|
78
81
|
specification_version: 3
|
79
82
|
summary: Surface slow code paths in your Rails 3 app via Growl / libnotify
|