log_parser 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/log_parser/client.rb +1 -1
- data/lib/log_parser/version.rb +1 -1
- data/test/log_parser/client_test.rb +20 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 234abf7d078d9cc9f0638a0e161850adea23cb0e
|
4
|
+
data.tar.gz: 480cfb8ca189dc6abb07a529f41b361e8548d08e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddbb96b52a46334907e36a170a2e70ccad3c2860e35d8be03c1064cd21e3c050ca4a5ce9bf4c0e3299c8033462faa02b4443d33dbf8a8c65d68747bb27fd2d6
|
7
|
+
data.tar.gz: a042e2502d53ee48fecd595053fea7223a54648e57329f9d82a1b1a0f90eb438ddca39791353e38ecd69fa6c049383e165b1b6acfd8a5a84215bf3a3519d5489
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ The class offers a some methods for scanning through a log `by_message(msg)`, `e
|
|
22
22
|
These methods can be chained together to refine your search. For example:
|
23
23
|
|
24
24
|
```Ruby
|
25
|
-
log = LogParser::Client.new('some.log')
|
25
|
+
log = LogParser::Client.new('some.log', line_pattern: LogParser::LOGGER_PATTERN)
|
26
26
|
log.errors.by_message('authentication failed').since(1.day.ago)
|
27
27
|
#=> ["[2014-11-13T23:12:14-07:00] ERROR [page_id 95239] Authentication failed with token ..."]
|
28
28
|
```
|
data/lib/log_parser/client.rb
CHANGED
data/lib/log_parser/version.rb
CHANGED
@@ -4,8 +4,9 @@ require 'log_parser'
|
|
4
4
|
class LogParser::ClientTest < MiniTest::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
@file = Pathname.new(File.join(
|
7
|
+
@file = Pathname.new(File.expand_path(File.join('..', '..', 'fixtures', 'example.log'), __FILE__))
|
8
8
|
@log = LogParser::Client.new(@file)
|
9
|
+
@date = DateTime.parse('2014-11-13T23:12:12-07:00')
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_initialize_with_string
|
@@ -66,10 +67,25 @@ class LogParser::ClientTest < MiniTest::Unit::TestCase
|
|
66
67
|
assert_equal ['page_id 24323', 'page_id 75645', 'page_id 95239'], prefixes
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
#
|
71
|
+
# Chaining
|
72
|
+
#
|
73
|
+
|
74
|
+
def test_prefix_is_chainable
|
75
|
+
prefix_lines = @log.by_prefix('foobar')
|
76
|
+
assert_respond_to prefix_lines, :by_message
|
77
|
+
assert_respond_to prefix_lines, :by_type
|
78
|
+
assert_respond_to prefix_lines, :since
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_filtering_by_chaining
|
82
|
+
lines = @log.by_prefix('page_id 24323').by_message(/saved \d+ reviews/i).since(@date).uniq
|
72
83
|
assert_equal 1, lines.count
|
73
84
|
assert_equal '[page_id 24323] Saved 10 reviews', lines.first.full_message
|
74
85
|
end
|
86
|
+
|
87
|
+
def test_no_chain_mutation
|
88
|
+
@log.by_prefix('page_id 24323').by_message(/saved \d+ reviews/i).since(@date).uniq
|
89
|
+
assert_equal 7, @log.lines.count
|
90
|
+
end
|
75
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.2.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Easily search log files
|