nightwatch 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nightwatch.rb +2 -0
- data/lib/nightwatch/configuration.rb +18 -0
- data/lib/nightwatch/mongo.rb +24 -0
- data/lib/nightwatch/monitor.rb +64 -63
- data/lib/nightwatch/version.rb +1 -1
- data/lib/nightwatch/web/public/css/app.css +7 -2
- data/lib/nightwatch/web/views/index.erb +3 -3
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf08834a8450c61d19d81eae776ed3894d815292
|
4
|
+
data.tar.gz: 746969a1c82a7564e5ca70216cf4349a64728404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b43abaaf82b85772e5b1c548c7022a7a367252d81025817b5b87514fc243029e24af854f1564efd4244a526f7727c9db1e118e2abeaef879f8ced363be8cb32
|
7
|
+
data.tar.gz: 6747d65e6c10b13d756fc186b3f0c34e5a3e1ed549ad00ca7340057658b1b25020490da7e1adb2ff971d9951f2207cabea98930668ba74fb6be44e82c0b85f22
|
data/lib/nightwatch.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'nightwatch/mongo'
|
3
|
+
|
4
|
+
module Nightwatch
|
5
|
+
def self.configure(&block)
|
6
|
+
Configuration.instance.instance_eval(&block)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Configuration
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@logger = Mongo.new
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor :logger
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
module Nightwatch
|
4
|
+
class Mongo
|
5
|
+
def initialize(opts = {})
|
6
|
+
@host = opts[:host] || '127.0.0.1'
|
7
|
+
@port = opts[:port] || 27017
|
8
|
+
@database = opts[:database] || 'nightwatch'
|
9
|
+
end
|
10
|
+
|
11
|
+
def log(record)
|
12
|
+
collection.insert(record)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def collection
|
18
|
+
@collection ||= begin
|
19
|
+
mongo = ::Mongo::MongoClient.new(@host, @port)
|
20
|
+
mongo[@database]['exceptions']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/nightwatch/monitor.rb
CHANGED
@@ -1,75 +1,76 @@
|
|
1
|
-
require 'mongo'
|
2
1
|
require 'socket'
|
2
|
+
require 'singleton'
|
3
|
+
require 'nightwatch/configuration'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.absolute_path(file)
|
10
|
-
File.absolute_path(file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
|
11
|
-
end
|
5
|
+
module Nightwatch
|
6
|
+
class ExceptionManager
|
7
|
+
include Singleton
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@exceptions = {}
|
18
|
-
end
|
9
|
+
def self.absolute_path(file)
|
10
|
+
File.absolute_path(file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
|
11
|
+
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
13
|
+
@@argv = Array.new(ARGV)
|
14
|
+
@@script = absolute_path($0)
|
23
15
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
collection = mongo['nightwatch']['exceptions']
|
28
|
-
host = Socket.gethostname
|
29
|
-
env = Hash[ENV.to_a]
|
30
|
-
|
31
|
-
@exceptions.each do |id, info|
|
32
|
-
exception, stack, ticks = info
|
33
|
-
klass = exception.class.name
|
34
|
-
|
35
|
-
collection.insert({
|
36
|
-
pid: $$,
|
37
|
-
script: @@script,
|
38
|
-
argv: @@argv,
|
39
|
-
env: env,
|
40
|
-
host: host,
|
41
|
-
class: klass,
|
42
|
-
message: exception.to_s,
|
43
|
-
stack: stack,
|
44
|
-
timestamp: ticks
|
45
|
-
})
|
16
|
+
def initialize
|
17
|
+
@exceptions = {}
|
18
|
+
@config = Configuration.instance
|
46
19
|
end
|
47
|
-
end
|
48
20
|
|
49
|
-
|
21
|
+
def add_exception(exception)
|
22
|
+
@exceptions[exception.object_id] = [exception, stack(exception), Time.now.to_i]
|
23
|
+
end
|
50
24
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
25
|
+
def commit!
|
26
|
+
host = Socket.gethostname
|
27
|
+
env = Hash[ENV.to_a]
|
28
|
+
|
29
|
+
@exceptions.each do |id, info|
|
30
|
+
exception, stack, ticks = info
|
31
|
+
klass = exception.class.name
|
32
|
+
|
33
|
+
record = {
|
34
|
+
pid: $$,
|
35
|
+
script: @@script,
|
36
|
+
argv: @@argv,
|
37
|
+
env: env,
|
38
|
+
host: host,
|
39
|
+
class: klass,
|
40
|
+
message: exception.to_s,
|
41
|
+
stack: stack,
|
42
|
+
timestamp: ticks
|
68
43
|
}
|
44
|
+
|
45
|
+
@config.logger.log(record)
|
69
46
|
end
|
70
47
|
end
|
71
48
|
|
72
|
-
|
49
|
+
private
|
50
|
+
|
51
|
+
def stack(exception)
|
52
|
+
stack = []
|
53
|
+
if exception.respond_to? :backtrace_locations
|
54
|
+
exception.backtrace_locations.each do |location|
|
55
|
+
stack << {
|
56
|
+
label: location.label,
|
57
|
+
path: self.class.absolute_path(location.absolute_path),
|
58
|
+
line: location.lineno
|
59
|
+
}
|
60
|
+
end
|
61
|
+
else
|
62
|
+
exception.backtrace.each do |location|
|
63
|
+
location.match(/^(.+?):(\d+)(|:in `(.+)')$/)
|
64
|
+
stack << {
|
65
|
+
label: $4,
|
66
|
+
path: self.class.absolute_path($1),
|
67
|
+
line: $2.to_i
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
stack
|
73
|
+
end
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -82,7 +83,7 @@ class Thread
|
|
82
83
|
orig_block.call
|
83
84
|
ensure
|
84
85
|
if $!
|
85
|
-
ExceptionManager.instance.add_exception($!)
|
86
|
+
Nightwatch::ExceptionManager.instance.add_exception($!)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
end
|
@@ -93,8 +94,8 @@ end
|
|
93
94
|
|
94
95
|
at_exit do
|
95
96
|
if $!
|
96
|
-
ExceptionManager.instance.add_exception($!)
|
97
|
+
Nightwatch::ExceptionManager.instance.add_exception($!)
|
97
98
|
end
|
98
99
|
|
99
|
-
ExceptionManager.instance.commit!
|
100
|
+
Nightwatch::ExceptionManager.instance.commit!
|
100
101
|
end
|
data/lib/nightwatch/version.rb
CHANGED
@@ -38,11 +38,12 @@ html, body {
|
|
38
38
|
.tile .support {
|
39
39
|
padding: 10px 15px;
|
40
40
|
}
|
41
|
-
.exception
|
41
|
+
.exception h5 {
|
42
42
|
font-size: 18px;
|
43
43
|
font-weight: normal;
|
44
44
|
margin: 0;
|
45
45
|
padding: 0;
|
46
|
+
line-height: 120%;
|
46
47
|
text-overflow: ellipsis;
|
47
48
|
overflow: hidden;
|
48
49
|
white-space: nowrap;
|
@@ -62,6 +63,7 @@ html, body {
|
|
62
63
|
padding: 20px 30px 10px 30px;
|
63
64
|
}
|
64
65
|
.exception-details h4 {
|
66
|
+
line-height: 120%;
|
65
67
|
text-overflow: ellipsis;
|
66
68
|
overflow: hidden;
|
67
69
|
white-space: nowrap;
|
@@ -111,5 +113,8 @@ html, body {
|
|
111
113
|
font-weight: 500;
|
112
114
|
}
|
113
115
|
.none {
|
114
|
-
color: #
|
116
|
+
color: #aaa;
|
117
|
+
}
|
118
|
+
.location {
|
119
|
+
font-family: Consolas, Monaco, monospace;
|
115
120
|
}
|
@@ -41,7 +41,7 @@
|
|
41
41
|
<ul class="exceptions">
|
42
42
|
<li ng-class="{ tile: true, exception: true, active: isActive(exception) }" ng-click="setActive(exception)" ng-repeat="exception in exceptions | exceptionFilter: { class: exceptionClass } | orderBy:'-timestamp'">
|
43
43
|
<div class="primary">
|
44
|
-
<
|
44
|
+
<h5><span class="class">{{exception.class}}</span><span ng-if="exception.message != exception.class">: <span class="message">{{exception.message}}</span></span></h5>
|
45
45
|
</div>
|
46
46
|
<div class="support">
|
47
47
|
<span class="host">{{exception.host}}</span>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
</div>
|
71
71
|
<div class="row">
|
72
72
|
<div class="col-md-2"><p class="name">Location</p></div>
|
73
|
-
<div class="col-md-10"><p>{{activeException.stack[0].label}} in {{activeException.stack[0].path | basename}}:{{activeException.stack[0].line}}</p></div>
|
73
|
+
<div class="col-md-10"><p><span class="location">{{activeException.stack[0].label}}</span> in {{activeException.stack[0].path | basename}}:{{activeException.stack[0].line}}</p></div>
|
74
74
|
</div>
|
75
75
|
<div class="row">
|
76
76
|
<div class="col-md-2"><p class="name">Script</p></div>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
<th>Line</th>
|
103
103
|
</tr>
|
104
104
|
<tr ng-repeat="frame in activeException.stack">
|
105
|
-
<td>{{frame.label}}</td>
|
105
|
+
<td><span class="location">{{frame.label}}</span></td>
|
106
106
|
<td>{{frame.path}}</td>
|
107
107
|
<td>{{frame.line}}</td>
|
108
108
|
</tr>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nightwatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schmich
|
@@ -101,6 +101,8 @@ executables:
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- lib/nightwatch/configuration.rb
|
105
|
+
- lib/nightwatch/mongo.rb
|
104
106
|
- lib/nightwatch/monitor.rb
|
105
107
|
- lib/nightwatch/version.rb
|
106
108
|
- lib/nightwatch/web/cli.rb
|