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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01983891b93d909cccf6c77177a2a3b4cbf042f8
4
- data.tar.gz: 4d798bdd4a5ca70ab0d0e8d36556c286dd6015f2
3
+ metadata.gz: bff4ae621b72803b366b033c088893aa448ab954
4
+ data.tar.gz: 3d111c1ad7f87f0edfdc18c1ce73321cd5dd86e3
5
5
  SHA512:
6
- metadata.gz: 7096493461a534a1d626f1311336ce0a6894927d74353f0e3e939eb02f375ae8939d22f2a30ddb30f09fc03af8bb1475543fd6ffb76fa89757cf68b14d78902a
7
- data.tar.gz: da05e6fd1edccf410696ae8b526431ef838b53fee57c018d7f258db3b8af03841bd4db44c8df11eec657a2b8fd05410b2e68ea1f3df0a12632a26a952d78ed69
6
+ metadata.gz: 987bde14792ce94f3730c779d1182feff6ac0b49d7ff49b1b2133083081499a6fcc534b69b2bd6c1fafc1cbed05bb958b8293b8068da6670a57ba8a780981725
7
+ data.tar.gz: c2a876bfd2c2f012405df2be06d78f6443b533167d0fc3639856e797c88d70c94f7a2f412699436e5b3cc86ac596fb3e02451e1e0be02a2bf99f2fc9dae43843
@@ -0,0 +1 @@
1
+ pkg/
@@ -1,3 +1,7 @@
1
+ # 1.1.0
2
+
3
+ - By default, include FATAL messages in the filtered log lines
4
+
1
5
  # 1.0.0
2
6
 
3
7
  - Initial release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resque_log_error_parser (0.0.0)
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.1)
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.0)
20
+ rack-protection (1.5.1)
21
21
  rack
22
22
  redis (3.0.5)
23
- redis-namespace (1.3.1)
24
- redis (~> 3.0.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.3)
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 File Error Parser
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 "resque_log_file_error_parser"
7
+ gem "resque_log_error_parser"
8
8
 
9
9
  ## Setup:
10
10
 
11
- ResqueLogFileErrorParser.queue = :queue_the_worker_should_listen_to
12
- ResqueLogFileErrorParser.on_error do |line_in_log_with_error|
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
- ResqueLogFileErrorParser.log_paths = ["some/other/*.log"]
19
+ ResqueLogErrorParser.log_paths = ["some/other/*.log"]
20
20
 
21
21
  ## Scheduling
22
22
 
23
- ResqueLogFileErrorParser is intended to be run periodically (e.g. every hour) using `resque_scheduler` or `cron`.
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
 
@@ -1,7 +1,7 @@
1
1
  module ResqueLogErrorParser
2
2
  DEFAULT_LOG_PATHS = ["log/*.log"]
3
3
  DEFAULT_LINE_DATE_FORMAT = '%Y-%m-%dT%H'
4
- DEFAULT_LINE_FILTER_KEYS = ["ERROR"]
4
+ DEFAULT_LINE_FILTER_KEYS = ["ERROR", "FATAL"]
5
5
 
6
6
  def self.queue=(q)
7
7
  @queue = q
@@ -2,11 +2,13 @@ module ResqueLogErrorParser
2
2
  class Lines < Array
3
3
 
4
4
  def filter_by(*filters)
5
- filters = [filters].flatten
6
- filtered_lines = self.dup
7
- filters.each do |filter|
8
- filtered_lines = filtered_lines.grep(/#{filter}/)
9
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module ResqueLogErrorParser
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -31,12 +31,13 @@ module ResqueLogErrorParser
31
31
  end
32
32
 
33
33
  def self.filters
34
- [self.time_filter_regex, ResqueLogErrorParser.line_filter_keys].flatten
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.time_filter_regex
38
- time_filter_str = Time.now.strftime(ResqueLogErrorParser.line_date_format)
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
@@ -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.194981 #28727] ERROR -- : Error line today
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 filtered by the given strings" do
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(1)
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(1)
32
- expect(lines).to include("E, [2013-10-06T17:01:04.194981 #28727] ERROR -- : Error line today")
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.0.0
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: 2013-11-07 00:00:00.000000000 Z
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