errlog 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/bin/errlogr +33 -16
- data/lib/errlog.rb +12 -6
- data/lib/errlog/packager.rb +10 -1
- data/lib/errlog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d90364c90b687b6ecaa2bcf73018f281eff1aaff
|
4
|
+
data.tar.gz: ec8ebdc1660cdbd7ad5d2542da2652785d76c6cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b62f8568e4cd90b0bd8cc73d1139d0f7f4e8b1751a03483119f5a95f39832107bc08b53407504b162f7c0c383f32494bfbc6d5de002d109b1c36dca102f0555
|
7
|
+
data.tar.gz: a4e69d69a7b12f6486a1730ef464466b79dd9d13ebb9c332b35681c206f570d44316db8e8c745c468ef57ddca67c076349c750942b4c9e85bb4d75edde9a1dad
|
data/.gitignore
CHANGED
data/bin/errlogr
CHANGED
@@ -30,6 +30,10 @@ Parameters
|
|
30
30
|
-a appname
|
31
31
|
set the application name. 'default' if not set.
|
32
32
|
|
33
|
+
-t test package
|
34
|
+
This mode allows developer to test the packed data. Pass your packed in base64 form instead of the
|
35
|
+
text and you will either see the unpacked data or an error message.
|
36
|
+
|
33
37
|
Some/all of there parameters might be set in the .errlog.yml file in the current path
|
34
38
|
or down the tree. Command-line parameters override these from configuration file.
|
35
39
|
|
@@ -51,20 +55,22 @@ end
|
|
51
55
|
usage if ARGV.length == 0
|
52
56
|
|
53
57
|
key, id, text, host, app, platform = nil, nil, '', nil, nil, nil
|
54
|
-
severity
|
58
|
+
severity = 100
|
59
|
+
|
60
|
+
test_mode = false
|
55
61
|
|
56
62
|
begin
|
57
63
|
n = 0
|
58
64
|
while n < ARGV.length do
|
59
65
|
arg = ARGV[n]
|
60
|
-
n
|
66
|
+
n += 1
|
61
67
|
case arg
|
62
68
|
when '-k'
|
63
69
|
key = ARGV[n]
|
64
|
-
n
|
70
|
+
n += 1
|
65
71
|
when '-i'
|
66
72
|
id = ARGV[n]
|
67
|
-
n
|
73
|
+
n += 1
|
68
74
|
when /^--local/
|
69
75
|
host = "http://localhost:8080"
|
70
76
|
when /^--warn/
|
@@ -73,10 +79,12 @@ begin
|
|
73
79
|
severity = Errlog::TRACE
|
74
80
|
when '-a'
|
75
81
|
app = ARGV[n]
|
76
|
-
n
|
82
|
+
n += 1
|
77
83
|
when '-p'
|
78
84
|
platform = ARGV[n]
|
79
|
-
n
|
85
|
+
n += 1
|
86
|
+
when '-t'
|
87
|
+
test_mode = true
|
80
88
|
else
|
81
89
|
text = arg.strip
|
82
90
|
break
|
@@ -99,10 +107,10 @@ if !key || !id
|
|
99
107
|
error "Neither id/key or configuration file was found"
|
100
108
|
usage
|
101
109
|
end
|
102
|
-
cfg
|
103
|
-
id
|
104
|
-
key
|
105
|
-
app
|
110
|
+
cfg = OpenStruct.new YAML::load_file(cfile)
|
111
|
+
id ||= cfg.account_id
|
112
|
+
key ||= cfg.account_key
|
113
|
+
app ||= cfg.application
|
106
114
|
platform ||= cfg.platform
|
107
115
|
end
|
108
116
|
|
@@ -113,12 +121,21 @@ end
|
|
113
121
|
|
114
122
|
usage if !key || !id || text.length == 0
|
115
123
|
|
116
|
-
Errlog.configure id, key, {host: host}
|
117
|
-
Errlog.context.platform
|
124
|
+
Errlog.configure id, key, { host: host }
|
125
|
+
Errlog.context.platform = platform
|
118
126
|
Errlog.context.application = app
|
119
127
|
|
120
|
-
|
121
|
-
|
122
|
-
|
128
|
+
if test_mode
|
129
|
+
packager = Errlog.default_packager
|
130
|
+
packager.throw_errors = true
|
131
|
+
puts "Decoded valid errlog package: \n#{packager.unpack(Base64.decode64(text)).inspect}"
|
132
|
+
exit 0
|
123
133
|
end
|
124
|
-
|
134
|
+
|
135
|
+
Errlog.report text, severity
|
136
|
+
if Errlog.wait
|
137
|
+
STDERR.puts "Error sending the report".red
|
138
|
+
exit 10
|
139
|
+
end
|
140
|
+
|
141
|
+
exit 0
|
data/lib/errlog.rb
CHANGED
@@ -41,6 +41,7 @@ module Errlog
|
|
41
41
|
end
|
42
42
|
|
43
43
|
@@configured = false
|
44
|
+
@@send_error = false
|
44
45
|
|
45
46
|
# Configure your instance. Sbhould be called before any other methods. Follow http://errorlog.co/help/rails
|
46
47
|
# to get your credentials
|
@@ -118,6 +119,10 @@ module Errlog
|
|
118
119
|
@@packager.pack(data)
|
119
120
|
end
|
120
121
|
|
122
|
+
def self.default_packager
|
123
|
+
@@packager
|
124
|
+
end
|
125
|
+
|
121
126
|
def self.protect component_name=nil, options={}, &block
|
122
127
|
context.protect component_name, options, &block
|
123
128
|
end
|
@@ -156,6 +161,12 @@ module Errlog
|
|
156
161
|
Thread.current[:errlog_context] || clear_context
|
157
162
|
end
|
158
163
|
|
164
|
+
def self.wait
|
165
|
+
@@send_threads.each { |t| t.weakref_alive? and t.join }
|
166
|
+
@@send_threads == []
|
167
|
+
@@send_error
|
168
|
+
end
|
169
|
+
|
159
170
|
private
|
160
171
|
|
161
172
|
def self.post src
|
@@ -175,19 +186,14 @@ module Errlog
|
|
175
186
|
error = "report refused: #{res.status}" if res.status != 200
|
176
187
|
rescue Exception => e
|
177
188
|
error = e
|
189
|
+
@@send_error = error
|
178
190
|
end
|
179
191
|
STDERR.puts "Error sending errlog: #{error}" if error
|
180
|
-
#puts "sent" unless error
|
181
192
|
yield error if block_given?
|
182
193
|
}
|
183
194
|
@@send_threads << WeakRef.new(t)
|
184
195
|
end
|
185
196
|
|
186
|
-
def self.wait
|
187
|
-
@@send_threads.each { |t| t.weakref_alive? and t.join }
|
188
|
-
@@send_threads == []
|
189
|
-
end
|
190
|
-
|
191
197
|
end
|
192
198
|
|
193
199
|
if defined?(Rails) && Rails.env == 'test'
|
data/lib/errlog/packager.rb
CHANGED
@@ -12,9 +12,14 @@ module Errlog
|
|
12
12
|
# transfer the report over the network. Normally you don't use it directly.
|
13
13
|
class Packager
|
14
14
|
|
15
|
-
|
15
|
+
attr_accessor :throw_errors
|
16
|
+
|
17
|
+
class Exception < Exception; end;
|
18
|
+
|
19
|
+
def initialize app_id, app_key, throw_errors = false
|
16
20
|
@appid = app_id
|
17
21
|
@key = app_key.length == 16 ? app_key : Base64.decode64(app_key)
|
22
|
+
@throw_errors = throw_errors
|
18
23
|
end
|
19
24
|
|
20
25
|
# AES-128 encrypt the block
|
@@ -57,14 +62,18 @@ module Errlog
|
|
57
62
|
data = block[1...-32]
|
58
63
|
sign = block[-32..-1]
|
59
64
|
if sign != Digest::SHA256.digest(data + @key)
|
65
|
+
puts "Sign does not match"
|
66
|
+
@throw_errors and raise Exception, "Wrong signature"
|
60
67
|
nil
|
61
68
|
else
|
62
69
|
JSON.parse Zlib::GzipReader.new(StringIO.new(data)).read
|
63
70
|
end
|
64
71
|
else
|
72
|
+
@throw_errors and raise Exception, "Unknown block type: #{block[0].ord}"
|
65
73
|
nil
|
66
74
|
end
|
67
75
|
rescue
|
76
|
+
@throw_errors and raise
|
68
77
|
nil
|
69
78
|
end
|
70
79
|
|
data/lib/errlog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: errlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: boss-protocol
|