httpd_log_parser 0.1.1 → 0.1.2
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/Guardfile +38 -0
- data/httpd_log_parser.gemspec +1 -0
- data/lib/httpd_log_parser.rb +14 -0
- data/lib/httpd_log_parser/base.rb +6 -1
- data/lib/httpd_log_parser/combined.rb +23 -1
- data/lib/httpd_log_parser/common.rb +15 -1
- data/lib/httpd_log_parser/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc88575c2ff0173d9e64cbb0ed1a91fc982d398f
|
4
|
+
data.tar.gz: 95dbdb562c486a37410fa793b90f881cc44d335a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 354237063d6066599e2fbb17f4d62ec6a5497e052d00086c58ae874bac23eb90e86b01cb88d6d2cab9a162b8933d4ce03d914dab31170367c5c0bd3cca06ee2a
|
7
|
+
data.tar.gz: 6c38bd911cf1b68bb3fd4fa6a505cc39a21865612d8adcf6078fd4cbcd2a16fbe955eb2d1d5936fa30558b98162cccac3c4bb7fc5e7c2e5e509e9a20224692ac
|
data/Guardfile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :test do
|
19
|
+
watch(%r{^test/.+_test\.rb$})
|
20
|
+
watch(%r{^test/test_.+\.rb$}) {'test' }
|
21
|
+
|
22
|
+
# Non-rails
|
23
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
24
|
+
|
25
|
+
# Rails 4
|
26
|
+
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
27
|
+
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
|
28
|
+
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
|
29
|
+
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
30
|
+
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
|
31
|
+
|
32
|
+
# Rails < 4
|
33
|
+
# watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
34
|
+
# watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
35
|
+
# watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
|
36
|
+
# watch(%r{^app/views/.+$}) { 'test/integration' }
|
37
|
+
# watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
|
38
|
+
end
|
data/httpd_log_parser.gemspec
CHANGED
data/lib/httpd_log_parser.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
require 'httpd_log_parser/base'
|
2
2
|
require 'httpd_log_parser/common'
|
3
3
|
require 'httpd_log_parser/combined'
|
4
|
+
|
5
|
+
class String
|
6
|
+
def to_unicage_str
|
7
|
+
return self.gsub(/_/, "\\_").gsub(/ /, "_")
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_unicage_nullchk
|
11
|
+
if self == "-"
|
12
|
+
return "_"
|
13
|
+
end
|
14
|
+
|
15
|
+
return self
|
16
|
+
end
|
17
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
2
|
module HttpdLogParser
|
3
3
|
class Base
|
4
|
-
attr_accessor :remote_host, :client_type, :user_name, :access_time, :request_code, :response_status, :object_bytes, :referer_uri, :user_agent, :request_method, :uri, :url, :query, :filters, :ignore_extentions
|
4
|
+
attr_accessor :remote_host, :client_type, :user_name, :access_time, :request_code, :response_status, :object_bytes, :referer_uri, :user_agent, :request_method, :uri, :url, :query, :filters, :ignore_extentions, :call_version, :other_data
|
5
5
|
@@format = '%d/%b/%Y:%H:%M:%S %Z'
|
6
|
+
@@format_unicage = '%Y-%m-%dT%H:%M:%S-%Z'
|
7
|
+
|
6
8
|
def initializer()
|
7
9
|
@ignore_extentions = []
|
8
10
|
@filters = []
|
@@ -39,5 +41,8 @@ module HttpdLogParser
|
|
39
41
|
|
40
42
|
self
|
41
43
|
end
|
44
|
+
|
45
|
+
|
42
46
|
end
|
47
|
+
|
43
48
|
end
|
@@ -24,10 +24,26 @@ module HttpdLogParser
|
|
24
24
|
self.user_agent = line[8]
|
25
25
|
request_datum = self.request_code.split(" ")
|
26
26
|
self.request_method = request_datum[0]
|
27
|
-
|
27
|
+
if ! request_datum[1].nil?
|
28
|
+
self.uri = request_datum[1]
|
29
|
+
else
|
30
|
+
self.uri = ""
|
31
|
+
end
|
32
|
+
if ! request_datum[2].nil?
|
33
|
+
self.call_version = request_datum[2]
|
34
|
+
else
|
35
|
+
self.call_version = ""
|
36
|
+
end
|
37
|
+
|
28
38
|
if ! self.uri.nil?
|
29
39
|
self.url, self.query = self.uri.split('?')
|
30
40
|
end
|
41
|
+
if ! line[9].nil?
|
42
|
+
self.other_data = line[9]
|
43
|
+
else
|
44
|
+
self.other_data = ""
|
45
|
+
end
|
46
|
+
|
31
47
|
rescue => e
|
32
48
|
$stderr.puts e
|
33
49
|
$stderr.puts line
|
@@ -45,8 +61,14 @@ module HttpdLogParser
|
|
45
61
|
Digest::MD5.hexdigest(self.referer_uri)
|
46
62
|
end
|
47
63
|
|
64
|
+
# get combined logformat data
|
48
65
|
def log
|
49
66
|
"#{self.remote_host} #{self.client_type} #{self.user_name} [#{self.access_time.strftime(@@format)}] \"#{self.request_code}\" #{self.response_status} #{self.object_bytes} \"#{self.referer_uri}\" \"#{self.user_agent}\""
|
50
67
|
end
|
68
|
+
|
69
|
+
# get unicage string data
|
70
|
+
def to_unicage
|
71
|
+
"#{self.remote_host} #{self.client_type.to_unicage_nullchk} #{self.access_time.strftime(@@format_unicage)} #{self.request_method} #{self.uri.to_unicage_str} #{self.call_version.to_unicage_str} #{self.object_bytes} #{self.referer_uri.to_unicage_str.to_unicage_nullchk} #{self.user_agent.to_unicage_str} #{self.other_data.to_unicage_str}"
|
72
|
+
end
|
51
73
|
end
|
52
74
|
end
|
@@ -18,7 +18,16 @@ module HttpdLogParser
|
|
18
18
|
self.object_bytes = line[6]
|
19
19
|
request_datum = self.request_code.split(" ")
|
20
20
|
self.request_method = request_datum[0]
|
21
|
-
|
21
|
+
if ! request_datum[1].nil?
|
22
|
+
self.uri = request_datum[1]
|
23
|
+
else
|
24
|
+
self.uri = ""
|
25
|
+
end
|
26
|
+
if ! request_datum[2].nil?
|
27
|
+
self.call_version = request_datum[2]
|
28
|
+
else
|
29
|
+
self.call_version = ""
|
30
|
+
end
|
22
31
|
if ! self.uri.nil?
|
23
32
|
self.url, self.query = self.uri.split('?')
|
24
33
|
end
|
@@ -38,5 +47,10 @@ module HttpdLogParser
|
|
38
47
|
def log
|
39
48
|
"#{self.remote_host} #{self.client_type} #{self.user_name} [#{self.access_time.strftime(@@format)}] \"#{self.request_code}\" #{self.response_status} #{self.object_bytes}"
|
40
49
|
end
|
50
|
+
|
51
|
+
# get unicage string data
|
52
|
+
def to_unicage
|
53
|
+
"#{self.remote_host} #{self.client_type.to_unicage_nullchk} #{self.access_time.strftime(@@format_unicage)} #{self.request_method} #{self.uri.to_unicage_str} #{self.call_version.to_unicage_str} #{self.object_bytes}"
|
54
|
+
end
|
41
55
|
end
|
42
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpd_log_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inpwjp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: This library is, convert ruby object from Apache log(common, combined).
|
56
70
|
email:
|
57
71
|
- inpw@mua.biglobe.ne.jp
|
@@ -63,6 +77,7 @@ files:
|
|
63
77
|
- ".gitignore"
|
64
78
|
- ".travis.yml"
|
65
79
|
- Gemfile
|
80
|
+
- Guardfile
|
66
81
|
- LICENSE.txt
|
67
82
|
- README.md
|
68
83
|
- Rakefile
|