scrolls 0.0.4 → 0.0.5
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.
- data/lib/scrolls.rb +22 -11
- data/lib/scrolls/version.rb +1 -1
- metadata +1 -1
data/lib/scrolls.rb
CHANGED
@@ -18,12 +18,20 @@ module Scrolls
|
|
18
18
|
|
19
19
|
attr_accessor :stream
|
20
20
|
|
21
|
-
def start(
|
22
|
-
|
23
|
-
|
21
|
+
def start(out = nil)
|
22
|
+
# This allows log_exceptions below to pick up the defined output,
|
23
|
+
# otherwise stream out to STDERR
|
24
|
+
@defined = out.nil? ? false : true
|
25
|
+
sync_stream(out)
|
24
26
|
log(:log => true, :start => true)
|
25
27
|
end
|
26
28
|
|
29
|
+
def sync_stream(out = nil)
|
30
|
+
out = STDOUT if out.nil?
|
31
|
+
@stream = out
|
32
|
+
@stream.sync = true
|
33
|
+
end
|
34
|
+
|
27
35
|
def mtx
|
28
36
|
@mtx ||= Mutex.new
|
29
37
|
end
|
@@ -31,7 +39,7 @@ module Scrolls
|
|
31
39
|
def write(data)
|
32
40
|
msg = unparse(data)
|
33
41
|
mtx.synchronize do
|
34
|
-
stream.puts(msg)
|
42
|
+
@stream.puts(msg)
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
@@ -80,19 +88,22 @@ module Scrolls
|
|
80
88
|
end
|
81
89
|
|
82
90
|
def log_exception(data, e)
|
91
|
+
sync_stream(STDERR) unless @defined
|
83
92
|
log(data.merge(
|
84
93
|
:exception => true,
|
85
94
|
:class => e.class,
|
86
95
|
:message => e.message,
|
87
96
|
:exception_id => e.object_id.abs
|
88
97
|
))
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
98
|
+
if e.backtrace
|
99
|
+
bt = e.backtrace.reverse
|
100
|
+
bt[0, bt.size-6].each do |line|
|
101
|
+
log(data.merge(
|
102
|
+
:exception => true,
|
103
|
+
:exception_id => e.object_id.abs,
|
104
|
+
:site => line.gsub(/[`'"]/, "")
|
105
|
+
))
|
106
|
+
end
|
96
107
|
end
|
97
108
|
end
|
98
109
|
end
|
data/lib/scrolls/version.rb
CHANGED