resque_log_error_parser 1.0.0 → 1.1.0
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/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +6 -6
- data/README.md +6 -6
- data/lib/resque_log_error_parser.rb +1 -1
- data/lib/resque_log_error_parser/lines.rb +7 -5
- data/lib/resque_log_error_parser/version.rb +1 -1
- data/lib/resque_log_error_parser/worker.rb +5 -4
- data/spec/fixtures/log/test.log +2 -1
- data/spec/resque_log_error_parser/lines_spec.rb +8 -3
- data/spec/resque_log_error_parser/worker_spec.rb +3 -2
- data/spec/resque_log_error_parser_spec.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bff4ae621b72803b366b033c088893aa448ab954
|
|
4
|
+
data.tar.gz: 3d111c1ad7f87f0edfdc18c1ce73321cd5dd86e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 987bde14792ce94f3730c779d1182feff6ac0b49d7ff49b1b2133083081499a6fcc534b69b2bd6c1fafc1cbed05bb958b8293b8068da6670a57ba8a780981725
|
|
7
|
+
data.tar.gz: c2a876bfd2c2f012405df2be06d78f6443b533167d0fc3639856e797c88d70c94f7a2f412699436e5b3cc86ac596fb3e02451e1e0be02a2bf99f2fc9dae43843
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pkg/
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
resque_log_error_parser (
|
|
4
|
+
resque_log_error_parser (1.0.0)
|
|
5
5
|
resque
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -11,17 +11,17 @@ GEM
|
|
|
11
11
|
diff-lcs (1.2.4)
|
|
12
12
|
method_source (0.8.2)
|
|
13
13
|
mono_logger (1.1.0)
|
|
14
|
-
multi_json (1.8.
|
|
14
|
+
multi_json (1.8.2)
|
|
15
15
|
pry (0.9.12.2)
|
|
16
16
|
coderay (~> 1.0.5)
|
|
17
17
|
method_source (~> 0.8)
|
|
18
18
|
slop (~> 3.4)
|
|
19
19
|
rack (1.5.2)
|
|
20
|
-
rack-protection (1.5.
|
|
20
|
+
rack-protection (1.5.1)
|
|
21
21
|
rack
|
|
22
22
|
redis (3.0.5)
|
|
23
|
-
redis-namespace (1.3.
|
|
24
|
-
redis (~> 3.0.
|
|
23
|
+
redis-namespace (1.3.2)
|
|
24
|
+
redis (~> 3.0.4)
|
|
25
25
|
resque (1.25.1)
|
|
26
26
|
mono_logger (~> 1.0)
|
|
27
27
|
multi_json (~> 1.0)
|
|
@@ -36,7 +36,7 @@ GEM
|
|
|
36
36
|
rspec-expectations (2.14.3)
|
|
37
37
|
diff-lcs (>= 1.1.3, < 2.0)
|
|
38
38
|
rspec-mocks (2.14.3)
|
|
39
|
-
sinatra (1.4.
|
|
39
|
+
sinatra (1.4.4)
|
|
40
40
|
rack (~> 1.4)
|
|
41
41
|
rack-protection (~> 1.4)
|
|
42
42
|
tilt (~> 1.3, >= 1.3.4)
|
data/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# Resque Log
|
|
1
|
+
# Resque Log Error Parser
|
|
2
2
|
|
|
3
3
|
Resque worker that parses log files given filters, and executes a callback of your choice.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
gem "
|
|
7
|
+
gem "resque_log_error_parser"
|
|
8
8
|
|
|
9
9
|
## Setup:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
ResqueLogErrorParser.queue = :queue_the_worker_should_listen_to
|
|
12
|
+
ResqueLogErrorParser.on_error do |line_in_log_with_error|
|
|
13
13
|
# You can email yourself, or report to PagerDuty like:
|
|
14
14
|
p = Pagerduty.new("key here")
|
|
15
15
|
p.trigger("Error found: #{line_in_log_with_error}")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# If your logs are located in a place other than "log/*.log", then you need to override the log_paths:
|
|
19
|
-
|
|
19
|
+
ResqueLogErrorParser.log_paths = ["some/other/*.log"]
|
|
20
20
|
|
|
21
21
|
## Scheduling
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
ResqueLogErrorParser is intended to be run periodically (e.g. every hour) using `resque_scheduler` or `cron`.
|
|
24
24
|
|
|
25
25
|
## Processing log entries
|
|
26
26
|
|
|
@@ -2,11 +2,13 @@ module ResqueLogErrorParser
|
|
|
2
2
|
class Lines < Array
|
|
3
3
|
|
|
4
4
|
def filter_by(*filters)
|
|
5
|
-
filters =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
filters = filters.flatten.compact
|
|
6
|
+
return self if filters.empty?
|
|
7
|
+
|
|
8
|
+
filtered_lines = filters.map do |filter|
|
|
9
|
+
self.grep(/#{filter}/)
|
|
10
|
+
end.flatten.uniq
|
|
11
|
+
|
|
10
12
|
self.class.new(filtered_lines)
|
|
11
13
|
end
|
|
12
14
|
|
|
@@ -31,12 +31,13 @@ module ResqueLogErrorParser
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.filters
|
|
34
|
-
|
|
34
|
+
ResqueLogErrorParser.line_filter_keys.map do |filter_key|
|
|
35
|
+
/#{self.time_now_filter}(.*)#{filter_key}/
|
|
36
|
+
end
|
|
35
37
|
end
|
|
36
38
|
|
|
37
|
-
def self.
|
|
38
|
-
|
|
39
|
-
/#{time_filter_str}/
|
|
39
|
+
def self.time_now_filter
|
|
40
|
+
Time.now.strftime(ResqueLogErrorParser.line_date_format)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
end
|
data/spec/fixtures/log/test.log
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
E, [2013-10-05T17:01:04.194981 #28727] ERROR -- : Error line yesterday
|
|
2
|
-
E, [2013-10-06T17:01:04.
|
|
2
|
+
E, [2013-10-06T17:01:04.194982 #28727] ERROR -- : Error line today
|
|
3
|
+
F, [2013-10-06T17:01:04.204983 #21462] FATAL -- : Pusher : error : {"code"=>4201, "message"=>"Pong reply not received"}
|
|
3
4
|
D, [2013-10-06T17:01:04.423205 #28727] DEBUG -- : No error
|
|
@@ -4,12 +4,14 @@ describe ResqueLogErrorParser::Lines do
|
|
|
4
4
|
|
|
5
5
|
describe "#filter_by" do
|
|
6
6
|
let(:lines) do
|
|
7
|
-
described_class.new(["hello", "world", "helloworld"])
|
|
7
|
+
described_class.new(["hello", "world", "helloworld", "should not be included"])
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
it "returns a Lines instance
|
|
10
|
+
it "returns a Lines instance matching ANY of the given filters" do
|
|
11
11
|
filtered_lines = lines.filter_by("llo", /orld/)
|
|
12
|
-
expect(filtered_lines.count).to eq(
|
|
12
|
+
expect(filtered_lines.count).to eq(3)
|
|
13
|
+
expect(filtered_lines).to include("hello")
|
|
14
|
+
expect(filtered_lines).to include("world")
|
|
13
15
|
expect(filtered_lines).to include("helloworld")
|
|
14
16
|
end
|
|
15
17
|
|
|
@@ -31,6 +33,9 @@ describe ResqueLogErrorParser::Lines do
|
|
|
31
33
|
it "returns the original" do
|
|
32
34
|
filtered_lines = lines.filter_by([])
|
|
33
35
|
expect(filtered_lines).to eq(lines)
|
|
36
|
+
|
|
37
|
+
filtered_lines = lines.filter_by(nil)
|
|
38
|
+
expect(filtered_lines).to eq(lines)
|
|
34
39
|
end
|
|
35
40
|
end
|
|
36
41
|
end
|
|
@@ -28,8 +28,9 @@ describe ResqueLogErrorParser::Worker do
|
|
|
28
28
|
lines << line
|
|
29
29
|
end
|
|
30
30
|
described_class.perform
|
|
31
|
-
expect(lines.count).to eq(
|
|
32
|
-
expect(lines).to include("E, [2013-10-06T17:01:04.
|
|
31
|
+
expect(lines.count).to eq(2)
|
|
32
|
+
expect(lines).to include("E, [2013-10-06T17:01:04.194982 #28727] ERROR -- : Error line today")
|
|
33
|
+
expect(lines).to include("F, [2013-10-06T17:01:04.204983 #21462] FATAL -- : Pusher : error : {\"code\"=>4201, \"message\"=>\"Pong reply not received\"}")
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -54,8 +54,8 @@ describe ResqueLogErrorParser do
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
describe ".line_filter_keys" do
|
|
57
|
-
it "defaults to ['ERROR']" do
|
|
58
|
-
expect(described_class.line_filter_keys).to eq(['ERROR'])
|
|
57
|
+
it "defaults to ['ERROR', 'FATAL']" do
|
|
58
|
+
expect(described_class.line_filter_keys).to eq(['ERROR', 'FATAL'])
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resque_log_error_parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- G5 Search Marketing
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: resque
|
|
@@ -61,6 +61,7 @@ executables: []
|
|
|
61
61
|
extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
|
63
63
|
files:
|
|
64
|
+
- .gitignore
|
|
64
65
|
- CHANGELOG.md
|
|
65
66
|
- Gemfile
|
|
66
67
|
- Gemfile.lock
|