server_log_parser 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +76 -0
- data/Rakefile +10 -0
- data/lib/server_log_parser/parser.rb +93 -0
- data/lib/server_log_parser/version.rb +5 -0
- data/lib/server_log_parser.rb +18 -0
- data/server_log_parser.gemspec +20 -0
- data/test/fixtures/line-with-slash-quote-in-referer.log +1 -0
- data/test/fixtures/line-with-slash-quote-in-request.log +1 -0
- data/test/fixtures/line.log +1 -0
- data/test/fixtures/log.log +5 -0
- data/test/parse_test.rb +109 -0
- data/test/server_log_parser_test.rb +16 -0
- data/test/test_helper.rb +7 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 174e076ac740e1a63f57d94615a20cddda8bcfe9
|
4
|
+
data.tar.gz: d909fc0142439bcb563bca4162f8a7f872fb6cbd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5336fafef49466bce811718e31d332588076084f949cecec63ea8c633a85476a7e8027c1f8ae9a6e90bb99ff47698c4ea11bc5c90bb7caa46497ef492946bbdc
|
7
|
+
data.tar.gz: 8defc3398fe35189011fc6975c11ac8cddec1801cd69a7ce259ff7dc3ba88fcfbf545b167bb9bfe7ac906f8ee05cc774cb6e81ee3adec4fd85626503d905a631
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2008, 2009 Simone Carletti <weppos@weppos.net>
|
2
|
+
Copyright (c) 2013 Nick Charlton
|
3
|
+
Copyright (c) 2016 Alexander Kurakin <kuraga333@mail.ru
|
4
|
+
|
5
|
+
MIT License
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# ServerLogParser
|
2
|
+
|
3
|
+
ServerLogParser provides a high-level Ruby library for parsing apache server log files
|
4
|
+
(common log format, with or without virtual hosts and combined log format) as used
|
5
|
+
by Apache, Nginx and others.
|
6
|
+
|
7
|
+
It's a fork of [ApacheLogRegex](https://github.com/weppos/apachelogregex),
|
8
|
+
which was in turn a port of [Apache::LogRegex 1.4 Perl module](http://search.cpan.org/~akira/Apache-ParseLog-1.02/ParseLog.pm).
|
9
|
+
where much of the regex parts come from.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```sh
|
14
|
+
gem install server_log_parser
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Initialization
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'server_log_parser'
|
23
|
+
|
24
|
+
parser = ServerLogParser::Parser(ServerLogParser::COMBINED_VIRTUAL_HOST)
|
25
|
+
# or:
|
26
|
+
# parser = ServerLogParser::Parser.new('%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"')
|
27
|
+
```
|
28
|
+
|
29
|
+
### Parsing
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
File.foreach('/var/log/apache/access.log') do |line|
|
33
|
+
parsed = parser.parse(line)
|
34
|
+
# {
|
35
|
+
# '%h' => '212.74.15.68',
|
36
|
+
# '%l' => '-',
|
37
|
+
# '%u' => '-',
|
38
|
+
# '%t' => '[23/Jan/2004:11:36:20 +0000]',
|
39
|
+
# '%r' => 'GET /images/previous.png HTTP/1.1',
|
40
|
+
# '%>s' => '200',
|
41
|
+
# '%b' => '2607',
|
42
|
+
# '%{Referer}i' => 'http://peterhi.dyndns.org/bandwidth/index.html',
|
43
|
+
# '%{User-Agent}i' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202'
|
44
|
+
# }
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
`ServerLogParser#parse` will silently ignore errors, but if you'd prefer,
|
49
|
+
`ServerLogParser#parse!` will raise a `ParseError` exception.
|
50
|
+
|
51
|
+
Apache log files use "-" to mean no data is present and these are replaced with nil,
|
52
|
+
like the "identity" and "user" values above. Request is split into a nested hash.
|
53
|
+
|
54
|
+
### Log Formats
|
55
|
+
|
56
|
+
The log format is specified using a rather verbose constant, which map out like:
|
57
|
+
|
58
|
+
Name | Constant | Apache Format
|
59
|
+
------------------------------------ | ------------------------------------------------- | ---------------------------------------------------------------------
|
60
|
+
Common Log Format | `ServerLogParser::COMMON_LOG_FORMAT` | `%h %l %u %t \"%r\" %>s %b`
|
61
|
+
Common Log Format with virtual hosts | `ServerLogParser::COMMON_LOG_FORMAT_VIRTUAL_HOST` | `%v %h %l %u %t \"%r\" %>s %b`
|
62
|
+
Combined | `ServerLogParser::COMBINED` | `%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"`
|
63
|
+
Combined with virtual hosts | `ServerLogParser::COMBINDED_VIRTUAL_HOST` | `%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"`
|
64
|
+
|
65
|
+
|
66
|
+
## Author
|
67
|
+
|
68
|
+
Alexander Kurakin <<kuraga333@mail.ru>>
|
69
|
+
|
70
|
+
## Feedback and contribute
|
71
|
+
|
72
|
+
<https://github.com/kuraga/server_log_parser/issues>
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
module ServerLogParser
|
2
|
+
|
3
|
+
class Parser
|
4
|
+
|
5
|
+
# Regexp instance used for parsing a log line.
|
6
|
+
attr_reader :regexp
|
7
|
+
|
8
|
+
# The list of field names that extracted from log format.
|
9
|
+
attr_reader :names
|
10
|
+
|
11
|
+
|
12
|
+
# Initializes a new parser instance with given log <tt>format</tt>.
|
13
|
+
def initialize(format)
|
14
|
+
@regexp = nil
|
15
|
+
@names = []
|
16
|
+
@format = parse_format(format)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parses <tt>line</tt> according to current log <tt>format</tt>
|
20
|
+
# and returns an hash of log field => value on success.
|
21
|
+
# Returns <tt>nil</tt> if <tt>line</tt> doesn't match current log <tt>format</tt>.
|
22
|
+
def parse(line)
|
23
|
+
row = line.to_s
|
24
|
+
row.chomp!
|
25
|
+
row.strip!
|
26
|
+
return unless match = regexp.match(row)
|
27
|
+
|
28
|
+
data = {}
|
29
|
+
names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line
|
30
|
+
data
|
31
|
+
end
|
32
|
+
|
33
|
+
# Same as <tt>ServerLogParser#parse</tt> but raises a <tt>ParseError</tt>
|
34
|
+
# if <tt>line</tt> doesn't match current <tt>format</tt>.
|
35
|
+
#
|
36
|
+
# ==== Raises
|
37
|
+
#
|
38
|
+
# ParseError:: if <tt>line</tt> doesn't match current <tt>format</tt>
|
39
|
+
#
|
40
|
+
def parse!(line)
|
41
|
+
parse(line) || raise(ParseError, "Invalid format `%s` for line `%s`" % [@format, line])
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
# Overwrite this method if you want to use some human-readable name for log fields.
|
48
|
+
# This method is called only once at <tt>parse_format</tt> time.
|
49
|
+
def rename_this_name(name)
|
50
|
+
name
|
51
|
+
end
|
52
|
+
|
53
|
+
# Parse log <tt>format</tt> into a suitable Regexp instance.
|
54
|
+
def parse_format(format)
|
55
|
+
format = format.to_s
|
56
|
+
format.chomp! # remove carriage return
|
57
|
+
format.strip! # remove leading and trailing space
|
58
|
+
format.gsub!(/[ \t]+/, ' ') # replace tabulations or spaces with a space
|
59
|
+
|
60
|
+
strip_quotes = proc { |string| string.gsub(/^\\"/, '').gsub(/\\"$/, '') }
|
61
|
+
find_quotes = proc { |string| string =~ /^\\"/ }
|
62
|
+
find_percent = proc { |string| string =~ /^%.*t$/ }
|
63
|
+
find_referrer_or_useragent = proc { |string| string =~ /Referer|User-Agent/ }
|
64
|
+
|
65
|
+
pattern = format.split(' ').map do |element|
|
66
|
+
has_quotes = !!find_quotes.call(element)
|
67
|
+
element = strip_quotes.call(element) if has_quotes
|
68
|
+
|
69
|
+
self.names << rename_this_name(element)
|
70
|
+
|
71
|
+
case
|
72
|
+
when has_quotes
|
73
|
+
if element == '%r' or find_referrer_or_useragent.call(element)
|
74
|
+
/"([^"\\]*(?:\\.[^"\\]*)*)"/
|
75
|
+
else
|
76
|
+
'\"([^\"]*)\"'
|
77
|
+
end
|
78
|
+
when find_percent.call(element)
|
79
|
+
'(\[[^\]]+\])'
|
80
|
+
when element == '%U'
|
81
|
+
'(.+?)'
|
82
|
+
else
|
83
|
+
'(\S*)'
|
84
|
+
end
|
85
|
+
end.join(' ')
|
86
|
+
|
87
|
+
@regexp = Regexp.new("^#{pattern}$")
|
88
|
+
format
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ServerLogParser
|
2
|
+
|
3
|
+
COMMON_LOG_FORMAT = '%h %l %u %t \"%r\" %>s %b'
|
4
|
+
COMMON_LOG_FORMAT_VIRTUAL_HOST = '%v %h %l %u %t \"%r\" %>s %b'
|
5
|
+
COMBINED = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"'
|
6
|
+
COMBINED_VIRTUAL_HOST = '%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"'
|
7
|
+
|
8
|
+
#
|
9
|
+
# = ParseError
|
10
|
+
#
|
11
|
+
# Raised in case the parser can't parse a log line with current +format+.
|
12
|
+
#
|
13
|
+
class ParseError < RuntimeError; end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'server_log_parser/version'
|
18
|
+
require 'server_log_parser/parser'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path("../lib/server_log_parser/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "server_log_parser"
|
5
|
+
spec.version = ServerLogParser::VERSION
|
6
|
+
spec.authors = ["Alexander Kurakin"]
|
7
|
+
spec.email = ["kuraga333@mail.ru"]
|
8
|
+
spec.summary = %q{Ruby library to parse server server log files using regular expressions.}
|
9
|
+
spec.description = %q{ServerLogParser provides a high-level Ruby library for parsing server server log files (common log format, with or without virtual hosts and combined log format) as used by Server, Nginx and others.}
|
10
|
+
spec.homepage = "https://github.com/kuraga/server_log_parser"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.test_files = spec.files.grep(%r{^test/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
18
|
+
spec.add_development_dependency "rake", "~> 10.5"
|
19
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
4.224.234.46 - - [20/Jul/2004:13:18:55 -0700] "GET /core/listing/pl_boat_detail.jsp?&units=Feet&checked_boats=1176818&slim=broker&&hosturl=giffordmarine&&ywo=giffordmarine& HTTP/1.1" 200 2888 "http://search.yahoo.com/bin/search?p=\"grady%20white%20306%20bimini\"" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; YPC 3.0.3; yplus 4.0.00d)"
|
@@ -0,0 +1 @@
|
|
1
|
+
212.74.15.68 - - [23/Jan/2004:11:36:20 +0000] "GET /images/previous.png=\" HTTP/1.1" 200 2607 "http://peterhi.dyndns.org/bandwidth/index.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202"
|
@@ -0,0 +1 @@
|
|
1
|
+
212.74.15.68 - - [23/Jan/2004:11:36:20 +0000] "GET /images/previous.png HTTP/1.1" 200 2607 "http://peterhi.dyndns.org/bandwidth/index.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202"
|
@@ -0,0 +1,5 @@
|
|
1
|
+
87.18.183.252 - - [13/Aug/2008:00:50:49 -0700] "GET /blog/index.xml HTTP/1.1" 302 527 "-" "Feedreader 3.13 (Powered by Newsbrain)"
|
2
|
+
79.28.16.191 - - [13/Aug/2008:00:50:55 -0700] "GET /blog/public/2008/08/gmail-offline-dati-a-rischio/gmaildown.png HTTP/1.1" 304 283 "-" "FeedDemon/2.7 (http://www.newsgator.com/; Microsoft Windows XP)"
|
3
|
+
79.28.16.191 - - [13/Aug/2008:00:50:55 -0700] "GET /blog/public/2008/08/nuovo-microsoft-webmaster-center/overview.png HTTP/1.1" 304 283 "-" "FeedDemon/2.7 (http://www.newsgator.com/; Microsoft Windows XP)"
|
4
|
+
69.150.40.169 - - [13/Aug/2008:00:51:06 -0700] "POST http://www.simonecarletti.com/mt4/mt-ttb.cgi/563 HTTP/1.1" 404 610 "-" "-"
|
5
|
+
217.220.110.75 - - [13/Aug/2008:00:51:02 -0700] "GET /blog/2007/05/microsoft-outlook-pst.php HTTP/1.1" 200 82331 "http://www.google.it/search?hl=it&q=outlook+pst+file+4+GB&meta=" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
|
data/test/parse_test.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe ServerLogParser::Parser do
|
4
|
+
|
5
|
+
describe "regular expression" do
|
6
|
+
|
7
|
+
it "should be correct" do
|
8
|
+
regexp = '(?-mix:^(\\S*) (\\S*) (\\S*) (\\[[^\\]]+\\]) (?-mix:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)") (\\S*) (\\S*) (?-mix:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)") (?-mix:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")$)'
|
9
|
+
|
10
|
+
assert_equal(@parser.regexp.to_s, regexp)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
@format = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"'
|
17
|
+
@parser = ServerLogParser::Parser.new(@format)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#parse" do
|
21
|
+
|
22
|
+
it "should parse line" do
|
23
|
+
expected = { '%h' => '212.74.15.68',
|
24
|
+
'%l' => '-',
|
25
|
+
'%u' => '-',
|
26
|
+
'%t' => '[23/Jan/2004:11:36:20 +0000]',
|
27
|
+
'%r' => 'GET /images/previous.png HTTP/1.1',
|
28
|
+
'%>s' => '200',
|
29
|
+
'%b' => '2607',
|
30
|
+
'%{Referer}i' => 'http://peterhi.dyndns.org/bandwidth/index.html',
|
31
|
+
'%{User-Agent}i' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202' }
|
32
|
+
results = @parser.parse(read_testcase('line.log'))
|
33
|
+
|
34
|
+
assert_kind_of(Hash, results)
|
35
|
+
assert_match_expected_hash(expected, results)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should parse line with slash quote in request" do
|
39
|
+
expected = { '%h' => '212.74.15.68',
|
40
|
+
'%l' => '-',
|
41
|
+
'%u' => '-',
|
42
|
+
'%t' => '[23/Jan/2004:11:36:20 +0000]',
|
43
|
+
'%r' => 'GET /images/previous.png=\" HTTP/1.1',
|
44
|
+
'%>s' => '200',
|
45
|
+
'%b' => '2607',
|
46
|
+
'%{Referer}i' => 'http://peterhi.dyndns.org/bandwidth/index.html',
|
47
|
+
'%{User-Agent}i' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202' }
|
48
|
+
results = @parser.parse(read_testcase('line-with-slash-quote-in-request.log'))
|
49
|
+
|
50
|
+
assert_kind_of(Hash, results)
|
51
|
+
assert_match_expected_hash(expected, results)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should parse line with slash quote in referer" do
|
55
|
+
expected = { '%h' => '4.224.234.46',
|
56
|
+
'%l' => '-',
|
57
|
+
'%u' => '-',
|
58
|
+
'%t' => '[20/Jul/2004:13:18:55 -0700]',
|
59
|
+
'%r' => 'GET /core/listing/pl_boat_detail.jsp?&units=Feet&checked_boats=1176818&slim=broker&&hosturl=giffordmarine&&ywo=giffordmarine& HTTP/1.1',
|
60
|
+
'%>s' => '200',
|
61
|
+
'%b' => '2888',
|
62
|
+
'%{Referer}i' => 'http://search.yahoo.com/bin/search?p=\"grady%20white%20306%20bimini\"',
|
63
|
+
'%{User-Agent}i' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; YPC 3.0.3; yplus 4.0.00d)' }
|
64
|
+
results = @parser.parse(read_testcase('line-with-slash-quote-in-referer.log'))
|
65
|
+
|
66
|
+
assert_kind_of(Hash, results)
|
67
|
+
assert_match_expected_hash(expected, results)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "return nil on invalid format" do
|
71
|
+
results = @parser.parse('foobar')
|
72
|
+
|
73
|
+
assert_nil(results)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#parse!" do
|
79
|
+
|
80
|
+
it "should work" do
|
81
|
+
testcase = read_testcase('line.log')
|
82
|
+
|
83
|
+
expected = @parser.parse(testcase)
|
84
|
+
results = @parser.parse!(testcase)
|
85
|
+
|
86
|
+
assert_equal(expected, results)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should raise on invalid format" do
|
90
|
+
error = assert_raises(ServerLogParser::ParseError) { @parser.parse!('foobar') }
|
91
|
+
assert_match(/Invalid format/, error.message)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def read_testcase(filename)
|
100
|
+
File.read("#{FIXTURES_PATH}/#{filename}")
|
101
|
+
end
|
102
|
+
|
103
|
+
def assert_match_expected_hash(expected, current)
|
104
|
+
expected.each do |key, value|
|
105
|
+
assert_equal(value, current[key], "Expected `#{key}` to match value `#{value}` but `#{current[:key]}`")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe ServerLogParser do
|
4
|
+
|
5
|
+
describe "constants" do
|
6
|
+
|
7
|
+
it "should be correct" do
|
8
|
+
assert_equal(ServerLogParser::COMMON_LOG_FORMAT, '%h %l %u %t \"%r\" %>s %b')
|
9
|
+
assert_equal(ServerLogParser::COMMON_LOG_FORMAT_VIRTUAL_HOST, '%v %h %l %u %t \"%r\" %>s %b')
|
10
|
+
assert_equal(ServerLogParser::COMBINED, '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"')
|
11
|
+
assert_equal(ServerLogParser::COMBINED_VIRTUAL_HOST, '%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: server_log_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Kurakin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.8'
|
55
|
+
description: ServerLogParser provides a high-level Ruby library for parsing server
|
56
|
+
server log files (common log format, with or without virtual hosts and combined
|
57
|
+
log format) as used by Server, Nginx and others.
|
58
|
+
email:
|
59
|
+
- kuraga333@mail.ru
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/server_log_parser.rb
|
71
|
+
- lib/server_log_parser/parser.rb
|
72
|
+
- lib/server_log_parser/version.rb
|
73
|
+
- server_log_parser.gemspec
|
74
|
+
- test/fixtures/line-with-slash-quote-in-referer.log
|
75
|
+
- test/fixtures/line-with-slash-quote-in-request.log
|
76
|
+
- test/fixtures/line.log
|
77
|
+
- test/fixtures/log.log
|
78
|
+
- test/parse_test.rb
|
79
|
+
- test/server_log_parser_test.rb
|
80
|
+
- test/test_helper.rb
|
81
|
+
homepage: https://github.com/kuraga/server_log_parser
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.4.5.1
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Ruby library to parse server server log files using regular expressions.
|
105
|
+
test_files:
|
106
|
+
- test/fixtures/line-with-slash-quote-in-referer.log
|
107
|
+
- test/fixtures/line-with-slash-quote-in-request.log
|
108
|
+
- test/fixtures/line.log
|
109
|
+
- test/fixtures/log.log
|
110
|
+
- test/parse_test.rb
|
111
|
+
- test/server_log_parser_test.rb
|
112
|
+
- test/test_helper.rb
|