ntail 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.1.0
@@ -10,7 +10,7 @@ module NginxTail
10
10
  DEFAULT_OPTIONS = {
11
11
  :interrupted => false,
12
12
  :running => true,
13
- :nginx => true,
13
+ :pattern => :nginx,
14
14
  :exit => 0,
15
15
  }
16
16
 
@@ -31,7 +31,7 @@ module NginxTail
31
31
 
32
32
  def run!
33
33
 
34
- LogLine.set_log_pattern(@options.nginx)
34
+ LogLine.set_pattern(@options.pattern)
35
35
 
36
36
  ['TERM', 'INT'].each do |signal|
37
37
  Signal.trap(signal) do
@@ -43,18 +43,18 @@ module NginxTail
43
43
  !self.unknown_referer?(http_referer) && !self.internal_referer?(http_referer)
44
44
  end
45
45
 
46
- def self.to_referer_s(http_referer)
47
- if self.unknown_referer? http_referer
48
- http_referer
49
- else begin
50
- # try to parse it as a URI, but with default value if un-parsable
51
- URI.parse(http_referer).host || http_referer
46
+ def self.to_referer_s(http_referer)
47
+ if self.unknown_referer? http_referer
48
+ http_referer
49
+ else begin
50
+ # try to parse it as a URI, but with default value if un-parsable
51
+ URI.parse(http_referer).host || http_referer
52
52
  rescue URI::InvalidURIError
53
- http_referer
53
+ http_referer
54
54
  end
55
55
  end
56
56
  end
57
-
57
+
58
58
  # this ensures the below module methods actually make sense...
59
59
  raise "Class #{base.name} should implement instance method 'http_referer'" unless base.instance_methods.map(&:to_s).include? 'http_referer'
60
60
 
@@ -83,8 +83,11 @@ module NginxTail
83
83
 
84
84
  @@log_pattern = NGINX_LOG_PATTERN
85
85
 
86
- def self.set_log_pattern(nginx_format)
87
- @@log_pattern = nginx_format ? NGINX_LOG_PATTERN : APACHE_LOG_PATTERN
86
+ def self.set_pattern(pattern)
87
+ @@log_pattern = case pattern
88
+ when :nginx then NGINX_LOG_PATTERN
89
+ when :apache then APACHE_LOG_PATTERN
90
+ end
88
91
  end
89
92
 
90
93
  NGINX_REQUEST_PATTERN = Regexp.compile(/\A(\S+) (.*?) (\S+)\Z/)
@@ -97,6 +100,7 @@ module NginxTail
97
100
  @remote_addr, @remote_user, @time_local, @request, @status, @body_bytes_sent, @http_referer, @http_user_agent, @proxy_addresses = $~.captures
98
101
  elsif @@log_pattern == APACHE_LOG_PATTERN
99
102
  @server_name, @remote_addr, @remote_log_name, @remote_user, @time_local, @request, @status, @body_bytes_sent, @http_referer, @http_user_agent, @http_cookie, @time_taken = $~.captures
103
+ @proxy_addresses = nil
100
104
  end
101
105
  if NGINX_REQUEST_PATTERN.match(@request)
102
106
  # counter example (ie. HTTP request that cannot by parsed)
@@ -40,7 +40,7 @@ module NginxTail
40
40
  end
41
41
 
42
42
  opts.on '--apache', "Try to match lines using the Apache log format instead of nginx (the default)" do |value|
43
- options.nginx = false
43
+ options.pattern = :apache
44
44
  end
45
45
 
46
46
  opts.on '--sleep [SECONDS]', '-s', Float, "Sleeps for the given number of seconds before processing the next line (--raw only)" do |value|
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ntail}
8
- s.version = "0.0.12"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Vandenberk"]
12
- s.date = %q{2011-08-08}
12
+ s.date = %q{2011-08-09}
13
13
  s.default_executable = %q{ntail}
14
14
  s.description = %q{A tail(1)-like utility for nginx log files. It supports parsing, filtering and formatting individual log lines.}
15
15
  s.email = %q{pvandenberk@mac.com}
@@ -71,7 +71,7 @@ Gem::Specification.new do |s|
71
71
  s.homepage = %q{http://github.com/pvdb/ntail}
72
72
  s.licenses = ["MIT"]
73
73
  s.require_paths = ["lib"]
74
- s.rubygems_version = %q{1.5.2}
74
+ s.rubygems_version = %q{1.6.1}
75
75
  s.summary = %q{A tail(1)-like utility for nginx log files}
76
76
  s.test_files = [
77
77
  "spec/application_spec.rb",
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 12
10
- version: 0.0.12
5
+ version: 0.1.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Peter Vandenberk
@@ -15,200 +10,152 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-08-08 00:00:00 +01:00
13
+ date: 2011-08-09 00:00:00 +01:00
19
14
  default_executable: ntail
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
22
- type: :runtime
17
+ name: rainbow
23
18
  requirement: &id001 !ruby/object:Gem::Requirement
24
19
  none: false
25
20
  requirements:
26
21
  - - ">="
27
22
  - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
23
  version: "0"
32
- name: rainbow
33
- version_requirements: *id001
24
+ type: :runtime
34
25
  prerelease: false
26
+ version_requirements: *id001
35
27
  - !ruby/object:Gem::Dependency
36
- type: :runtime
28
+ name: user-agent
37
29
  requirement: &id002 !ruby/object:Gem::Requirement
38
30
  none: false
39
31
  requirements:
40
32
  - - ">="
41
33
  - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
34
  version: "0"
46
- name: user-agent
47
- version_requirements: *id002
35
+ type: :runtime
48
36
  prerelease: false
37
+ version_requirements: *id002
49
38
  - !ruby/object:Gem::Dependency
50
- type: :runtime
39
+ name: treetop
51
40
  requirement: &id003 !ruby/object:Gem::Requirement
52
41
  none: false
53
42
  requirements:
54
43
  - - ~>
55
44
  - !ruby/object:Gem::Version
56
- hash: 21
57
- segments:
58
- - 1
59
- - 4
60
- - 9
61
45
  version: 1.4.9
62
- name: treetop
63
- version_requirements: *id003
46
+ type: :runtime
64
47
  prerelease: false
48
+ version_requirements: *id003
65
49
  - !ruby/object:Gem::Dependency
66
- type: :runtime
50
+ name: sequel
67
51
  requirement: &id004 !ruby/object:Gem::Requirement
68
52
  none: false
69
53
  requirements:
70
54
  - - ">="
71
55
  - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
56
  version: "0"
76
- name: sequel
77
- version_requirements: *id004
57
+ type: :runtime
78
58
  prerelease: false
59
+ version_requirements: *id004
79
60
  - !ruby/object:Gem::Dependency
80
- type: :runtime
61
+ name: mongoid
81
62
  requirement: &id005 !ruby/object:Gem::Requirement
82
63
  none: false
83
64
  requirements:
84
65
  - - ">="
85
66
  - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
67
  version: "0"
90
- name: mongoid
91
- version_requirements: *id005
68
+ type: :runtime
92
69
  prerelease: false
70
+ version_requirements: *id005
93
71
  - !ruby/object:Gem::Dependency
94
- type: :runtime
72
+ name: sqlite3-ruby
95
73
  requirement: &id006 !ruby/object:Gem::Requirement
96
74
  none: false
97
75
  requirements:
98
76
  - - ">="
99
77
  - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
78
  version: "0"
104
- name: sqlite3-ruby
105
- version_requirements: *id006
79
+ type: :runtime
106
80
  prerelease: false
81
+ version_requirements: *id006
107
82
  - !ruby/object:Gem::Dependency
108
- type: :development
83
+ name: rake
109
84
  requirement: &id007 !ruby/object:Gem::Requirement
110
85
  none: false
111
86
  requirements:
112
87
  - - ">="
113
88
  - !ruby/object:Gem::Version
114
- hash: 63
115
- segments:
116
- - 0
117
- - 9
118
- - 2
119
89
  version: 0.9.2
120
- name: rake
121
- version_requirements: *id007
90
+ type: :development
122
91
  prerelease: false
92
+ version_requirements: *id007
123
93
  - !ruby/object:Gem::Dependency
124
- type: :development
94
+ name: shoulda
125
95
  requirement: &id008 !ruby/object:Gem::Requirement
126
96
  none: false
127
97
  requirements:
128
98
  - - ">="
129
99
  - !ruby/object:Gem::Version
130
- hash: 3
131
- segments:
132
- - 0
133
100
  version: "0"
134
- name: shoulda
135
- version_requirements: *id008
101
+ type: :development
136
102
  prerelease: false
103
+ version_requirements: *id008
137
104
  - !ruby/object:Gem::Dependency
138
- type: :development
105
+ name: bundler
139
106
  requirement: &id009 !ruby/object:Gem::Requirement
140
107
  none: false
141
108
  requirements:
142
109
  - - ~>
143
110
  - !ruby/object:Gem::Version
144
- hash: 23
145
- segments:
146
- - 1
147
- - 0
148
- - 0
149
111
  version: 1.0.0
150
- name: bundler
151
- version_requirements: *id009
112
+ type: :development
152
113
  prerelease: false
114
+ version_requirements: *id009
153
115
  - !ruby/object:Gem::Dependency
154
- type: :development
116
+ name: jeweler
155
117
  requirement: &id010 !ruby/object:Gem::Requirement
156
118
  none: false
157
119
  requirements:
158
120
  - - ~>
159
121
  - !ruby/object:Gem::Version
160
- hash: 1
161
- segments:
162
- - 1
163
- - 5
164
- - 1
165
122
  version: 1.5.1
166
- name: jeweler
167
- version_requirements: *id010
123
+ type: :development
168
124
  prerelease: false
125
+ version_requirements: *id010
169
126
  - !ruby/object:Gem::Dependency
170
- type: :development
127
+ name: rcov
171
128
  requirement: &id011 !ruby/object:Gem::Requirement
172
129
  none: false
173
130
  requirements:
174
131
  - - ">="
175
132
  - !ruby/object:Gem::Version
176
- hash: 3
177
- segments:
178
- - 0
179
133
  version: "0"
180
- name: rcov
181
- version_requirements: *id011
134
+ type: :development
182
135
  prerelease: false
136
+ version_requirements: *id011
183
137
  - !ruby/object:Gem::Dependency
184
- type: :development
138
+ name: geoip
185
139
  requirement: &id012 !ruby/object:Gem::Requirement
186
140
  none: false
187
141
  requirements:
188
142
  - - ">="
189
143
  - !ruby/object:Gem::Version
190
- hash: 3
191
- segments:
192
- - 0
193
144
  version: "0"
194
- name: geoip
195
- version_requirements: *id012
145
+ type: :development
196
146
  prerelease: false
147
+ version_requirements: *id012
197
148
  - !ruby/object:Gem::Dependency
198
- type: :development
149
+ name: rspec
199
150
  requirement: &id013 !ruby/object:Gem::Requirement
200
151
  none: false
201
152
  requirements:
202
153
  - - ">="
203
154
  - !ruby/object:Gem::Version
204
- hash: 9
205
- segments:
206
- - 2
207
- - 5
208
155
  version: "2.5"
209
- name: rspec
210
- version_requirements: *id013
156
+ type: :development
211
157
  prerelease: false
158
+ version_requirements: *id013
212
159
  description: A tail(1)-like utility for nginx log files. It supports parsing, filtering and formatting individual log lines.
213
160
  email: pvandenberk@mac.com
214
161
  executables:
@@ -281,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
228
  requirements:
282
229
  - - ">="
283
230
  - !ruby/object:Gem::Version
284
- hash: 3
231
+ hash: 3911562482535553206
285
232
  segments:
286
233
  - 0
287
234
  version: "0"
@@ -290,14 +237,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
237
  requirements:
291
238
  - - ">="
292
239
  - !ruby/object:Gem::Version
293
- hash: 3
294
- segments:
295
- - 0
296
240
  version: "0"
297
241
  requirements: []
298
242
 
299
243
  rubyforge_project:
300
- rubygems_version: 1.5.2
244
+ rubygems_version: 1.6.1
301
245
  signing_key:
302
246
  specification_version: 3
303
247
  summary: A tail(1)-like utility for nginx log files