vizi_translator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +44 -0
- data/build_gem1.bat +1 -0
- data/build_gem2.bat +1 -0
- data/build_gem3.bat +1 -0
- data/build_gem4.bat +1 -0
- data/data/index.md +17 -0
- data/data/testfile.txt +4 -0
- data/doc/Object.html +200 -0
- data/doc/ParserTest.html +268 -0
- data/doc/README_rdoc.html +128 -0
- data/doc/Rakefile.html +148 -0
- data/doc/Visit.html +487 -0
- data/doc/VisitList.html +385 -0
- data/doc/Vizi/LogFormat.html +377 -0
- data/doc/Vizi/LogParser.html +551 -0
- data/doc/Vizi/Translator.html +302 -0
- data/doc/Vizi/UnSupportedLanguage.html +212 -0
- data/doc/Vizi/Visit.html +487 -0
- data/doc/Vizi/VisitList.html +386 -0
- data/doc/Vizi.html +159 -0
- data/doc/ViziLogFormat.html +382 -0
- data/doc/ViziLogParser.html +551 -0
- data/doc/created.rid +4 -0
- data/doc/docs/Whois_Documentation.doc +0 -0
- data/doc/formats/apache-custom-log.pdf +0 -0
- data/doc/formats/apache.rtf +238 -0
- data/doc/formats/format-descriptions.xls +0 -0
- data/doc/formats/w3c-extended.pdf +0 -0
- data/doc/formats/w3c-extended.rtf +135 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +68 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/vizi/parser_rb.html +63 -0
- data/doc/lib/vizi/vizi_tracker_rb.html +63 -0
- data/doc/lib/vizi/vizi_translator.html +104 -0
- data/doc/lib/vizi/vizi_translator_rb.html +69 -0
- data/doc/lib/vizi_log_parser_rb.html +56 -0
- data/doc/lib/vizi_tracker_rb.html +56 -0
- data/doc/lib/vizi_translator_rb.html +54 -0
- data/doc/rdoc.css +759 -0
- data/doc/test/parser_test_rb.html +54 -0
- data/doc/test/test_helper_rb.html +56 -0
- data/doc/testit_rb.html +63 -0
- data/geany_run_script.bat +6 -0
- data/lib/vizi/vizi_translator +11 -0
- data/lib/vizi/vizi_translator.rb +68 -0
- data/lib/vizi_translator.rb +5 -0
- data/log/system.log +1 -0
- data/testit.rb +51 -0
- data/vizi_translator.gemspec +17 -0
- metadata +122 -0
@@ -0,0 +1,382 @@
|
|
1
|
+
<?xml version="1.0" encoding="IBM437"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: ViziLogFormat</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="./index.html">Home</a>
|
25
|
+
<a href="./index.html#classes">Classes</a>
|
26
|
+
<a href="./index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="./lib/vizi/parser_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/vizi/parser.rb">lib/vizi/parser.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link"><a href="Object.html">Object</a></p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-new">::new</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-i-parse_format">#parse_format</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-i-process_directive">#process_directive</a></li>
|
73
|
+
|
74
|
+
</ul>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div id="project-metadata">
|
82
|
+
|
83
|
+
|
84
|
+
<div id="fileindex-section" class="section project-section">
|
85
|
+
<h3 class="section-header">Files</h3>
|
86
|
+
<ul>
|
87
|
+
|
88
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
89
|
+
|
90
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
91
|
+
|
92
|
+
</ul>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<div id="classindex-section" class="section project-section">
|
97
|
+
<h3 class="section-header">Class/Module Index
|
98
|
+
<span class="search-toggle"><img src="./images/find.png"
|
99
|
+
height="16" width="16" alt="[+]"
|
100
|
+
title="show/hide quicksearch" /></span></h3>
|
101
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
102
|
+
<fieldset>
|
103
|
+
<legend>Quicksearch</legend>
|
104
|
+
<input type="text" name="quicksearch" value=""
|
105
|
+
class="quicksearch-field" />
|
106
|
+
</fieldset>
|
107
|
+
</form>
|
108
|
+
|
109
|
+
<ul class="link-list">
|
110
|
+
|
111
|
+
<li><a href="./Object.html">Object</a></li>
|
112
|
+
|
113
|
+
<li><a href="./ParserTest.html">ParserTest</a></li>
|
114
|
+
|
115
|
+
<li><a href="./Visit.html">Visit</a></li>
|
116
|
+
|
117
|
+
<li><a href="./VisitList.html">VisitList</a></li>
|
118
|
+
|
119
|
+
<li><a href="./ViziLogFormat.html">ViziLogFormat</a></li>
|
120
|
+
|
121
|
+
<li><a href="./ViziLogParser.html">ViziLogParser</a></li>
|
122
|
+
|
123
|
+
</ul>
|
124
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
|
131
|
+
<div id="documentation">
|
132
|
+
<h1 class="class">ViziLogFormat</h1>
|
133
|
+
|
134
|
+
<div id="description" class="description">
|
135
|
+
|
136
|
+
<h1><a href="ViziLogFormat.html">ViziLogFormat</a></h1>
|
137
|
+
<table class="rdoc-list"><tr><td class="rdoc-term"><p>Author</p></td>
|
138
|
+
<td>
|
139
|
+
<p>Al Kivi <admin@viztrax.com></p>
|
140
|
+
</td></tr><tr><td class="rdoc-term"><p>License</p></td>
|
141
|
+
<td>
|
142
|
+
<p>MIT</p>
|
143
|
+
</td></tr></table>
|
144
|
+
|
145
|
+
</div><!-- description -->
|
146
|
+
|
147
|
+
|
148
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<!-- Constants -->
|
155
|
+
<div id="constants-list" class="section">
|
156
|
+
<h3 class="section-header">Constants</h3>
|
157
|
+
<dl>
|
158
|
+
|
159
|
+
<dt><a name="DIRECTIVES">DIRECTIVES</a></dt>
|
160
|
+
|
161
|
+
<dd class="description"><p>add more format directives here..</p></dd>
|
162
|
+
|
163
|
+
|
164
|
+
</dl>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<!-- Attributes -->
|
170
|
+
<div id="attribute-method-details" class="method-section section">
|
171
|
+
<h3 class="section-header">Attributes</h3>
|
172
|
+
|
173
|
+
|
174
|
+
<div id="format-attribute-method" class="method-detail">
|
175
|
+
<a name="format"></a>
|
176
|
+
|
177
|
+
<div class="method-heading attribute-method-heading">
|
178
|
+
<span class="method-name">format</span><span
|
179
|
+
class="attribute-access-type">[R]</span>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div class="method-description">
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div id="format_regex-attribute-method" class="method-detail">
|
190
|
+
<a name="format_regex"></a>
|
191
|
+
|
192
|
+
<div class="method-heading attribute-method-heading">
|
193
|
+
<span class="method-name">format_regex</span><span
|
194
|
+
class="attribute-access-type">[R]</span>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div class="method-description">
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div id="format_symbols-attribute-method" class="method-detail">
|
205
|
+
<a name="format_symbols"></a>
|
206
|
+
|
207
|
+
<div class="method-heading attribute-method-heading">
|
208
|
+
<span class="method-name">format_symbols</span><span
|
209
|
+
class="attribute-access-type">[R]</span>
|
210
|
+
</div>
|
211
|
+
|
212
|
+
<div class="method-description">
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
|
219
|
+
<div id="name-attribute-method" class="method-detail">
|
220
|
+
<a name="name"></a>
|
221
|
+
|
222
|
+
<div class="method-heading attribute-method-heading">
|
223
|
+
<span class="method-name">name</span><span
|
224
|
+
class="attribute-access-type">[R]</span>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
<div class="method-description">
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
</div><!-- attribute-method-details -->
|
235
|
+
|
236
|
+
|
237
|
+
<!-- Methods -->
|
238
|
+
|
239
|
+
<div id="public-class-method-details" class="method-section section">
|
240
|
+
<h3 class="section-header">Public Class Methods</h3>
|
241
|
+
|
242
|
+
|
243
|
+
<div id="new-method" class="method-detail ">
|
244
|
+
<a name="method-c-new"></a>
|
245
|
+
|
246
|
+
|
247
|
+
<div class="method-heading">
|
248
|
+
<span class="method-name">new</span><span
|
249
|
+
class="method-args">(name, format)</span>
|
250
|
+
<span class="method-click-advice">click to toggle source</span>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
|
254
|
+
<div class="method-description">
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
<div class="method-source-code" id="new-source">
|
261
|
+
<pre>
|
262
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 39</span>
|
263
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>)
|
264
|
+
<span class="ruby-ivar">@name</span>, <span class="ruby-ivar">@format</span> = <span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>
|
265
|
+
<span class="ruby-identifier">parse_format</span>(<span class="ruby-identifier">format</span>)
|
266
|
+
<span class="ruby-keyword">end</span></pre>
|
267
|
+
</div><!-- new-source -->
|
268
|
+
|
269
|
+
</div>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
</div><!-- new-method -->
|
275
|
+
|
276
|
+
|
277
|
+
</div><!-- public-class-method-details -->
|
278
|
+
|
279
|
+
<div id="public-instance-method-details" class="method-section section">
|
280
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
281
|
+
|
282
|
+
|
283
|
+
<div id="parse_format-method" class="method-detail ">
|
284
|
+
<a name="method-i-parse_format"></a>
|
285
|
+
|
286
|
+
|
287
|
+
<div class="method-heading">
|
288
|
+
<span class="method-name">parse_format</span><span
|
289
|
+
class="method-args">(format)</span>
|
290
|
+
<span class="method-click-advice">click to toggle source</span>
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
<div class="method-description">
|
295
|
+
|
296
|
+
<p>The symbols are used to map the log to the env variables The regex is used
|
297
|
+
when checking what format the log is and to extract data</p>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
<div class="method-source-code" id="parse_format-source">
|
302
|
+
<pre>
|
303
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 46</span>
|
304
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_format</span>(<span class="ruby-identifier">format</span>)
|
305
|
+
<span class="ruby-identifier">format_directive</span> = <span class="ruby-node">/%(.*?)(\{.*?\})?([#{[DIRECTIVES.keys.join('|')]}])([\s\\"]*)/</span>
|
306
|
+
<span class="ruby-identifier">log_format_symbols</span> = []
|
307
|
+
<span class="ruby-identifier">format_regex</span> = <span class="ruby-string">""</span>
|
308
|
+
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">format_directive</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">condition</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">ignored</span><span class="ruby-operator">|</span>
|
309
|
+
<span class="ruby-identifier">log_format</span>, <span class="ruby-identifier">match_regex</span> = <span class="ruby-identifier">process_directive</span>(<span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">condition</span>)
|
310
|
+
<span class="ruby-identifier">ignored</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\s/</span>, <span class="ruby-string">'\s'</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ignored</span>.<span class="ruby-identifier">nil?</span>
|
311
|
+
<span class="ruby-identifier">log_format_symbols</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">log_format</span>
|
312
|
+
<span class="ruby-identifier">format_regex</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"(#{match_regex})#{ignored}"</span>
|
313
|
+
<span class="ruby-keyword">end</span>
|
314
|
+
<span class="ruby-ivar">@format_symbols</span> = <span class="ruby-identifier">log_format_symbols</span>
|
315
|
+
<span class="ruby-ivar">@format_regex</span> = <span class="ruby-node">/^#{format_regex}/</span>
|
316
|
+
<span class="ruby-keyword">end</span></pre>
|
317
|
+
</div><!-- parse_format-source -->
|
318
|
+
|
319
|
+
</div>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
</div><!-- parse_format-method -->
|
325
|
+
|
326
|
+
|
327
|
+
<div id="process_directive-method" class="method-detail ">
|
328
|
+
<a name="method-i-process_directive"></a>
|
329
|
+
|
330
|
+
|
331
|
+
<div class="method-heading">
|
332
|
+
<span class="method-name">process_directive</span><span
|
333
|
+
class="method-args">(directive_char, subdirective, condition)</span>
|
334
|
+
<span class="method-click-advice">click to toggle source</span>
|
335
|
+
</div>
|
336
|
+
|
337
|
+
|
338
|
+
<div class="method-description">
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
<div class="method-source-code" id="process_directive-source">
|
345
|
+
<pre>
|
346
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 60</span>
|
347
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process_directive</span>(<span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">condition</span>)
|
348
|
+
<span class="ruby-identifier">directive</span> = <span class="ruby-constant">DIRECTIVES</span>[<span class="ruby-identifier">directive_char</span>]
|
349
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">directive_char</span>
|
350
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">'i'</span>
|
351
|
+
<span class="ruby-identifier">log_format</span> = <span class="ruby-identifier">subdirective</span>[<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">'_'</span>).<span class="ruby-identifier">to_sym</span>
|
352
|
+
[<span class="ruby-identifier">log_format</span>, <span class="ruby-identifier">directive</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">source</span>]
|
353
|
+
<span class="ruby-keyword">else</span>
|
354
|
+
[<span class="ruby-identifier">directive</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">directive</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">source</span>]
|
355
|
+
<span class="ruby-keyword">end</span>
|
356
|
+
<span class="ruby-keyword">end</span></pre>
|
357
|
+
</div><!-- process_directive-source -->
|
358
|
+
|
359
|
+
</div>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
</div><!-- process_directive-method -->
|
365
|
+
|
366
|
+
|
367
|
+
</div><!-- public-instance-method-details -->
|
368
|
+
|
369
|
+
</div><!-- 5Buntitled-5D -->
|
370
|
+
|
371
|
+
|
372
|
+
</div><!-- documentation -->
|
373
|
+
|
374
|
+
<div id="validator-badges">
|
375
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
376
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
377
|
+
Rdoc Generator</a> 2</small>.</p>
|
378
|
+
</div>
|
379
|
+
|
380
|
+
</body>
|
381
|
+
</html>
|
382
|
+
|
@@ -0,0 +1,551 @@
|
|
1
|
+
<?xml version="1.0" encoding="IBM437"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: ViziLogParser</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="./index.html">Home</a>
|
25
|
+
<a href="./index.html#classes">Classes</a>
|
26
|
+
<a href="./index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="./lib/vizi/parser_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/vizi/parser.rb">lib/vizi/parser.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link"><a href="Object.html">Object</a></p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-new">::new</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-i-build_format">#build_format</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-i-check_format">#check_format</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-initialize_known_formats">#initialize_known_formats</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-match_partial">#match_partial</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-parse_line">#parse_line</a></li>
|
79
|
+
|
80
|
+
</ul>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="project-metadata">
|
88
|
+
|
89
|
+
|
90
|
+
<div id="fileindex-section" class="section project-section">
|
91
|
+
<h3 class="section-header">Files</h3>
|
92
|
+
<ul>
|
93
|
+
|
94
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
95
|
+
|
96
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
97
|
+
|
98
|
+
</ul>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
<div id="classindex-section" class="section project-section">
|
103
|
+
<h3 class="section-header">Class/Module Index
|
104
|
+
<span class="search-toggle"><img src="./images/find.png"
|
105
|
+
height="16" width="16" alt="[+]"
|
106
|
+
title="show/hide quicksearch" /></span></h3>
|
107
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
108
|
+
<fieldset>
|
109
|
+
<legend>Quicksearch</legend>
|
110
|
+
<input type="text" name="quicksearch" value=""
|
111
|
+
class="quicksearch-field" />
|
112
|
+
</fieldset>
|
113
|
+
</form>
|
114
|
+
|
115
|
+
<ul class="link-list">
|
116
|
+
|
117
|
+
<li><a href="./Object.html">Object</a></li>
|
118
|
+
|
119
|
+
<li><a href="./ParserTest.html">ParserTest</a></li>
|
120
|
+
|
121
|
+
<li><a href="./Visit.html">Visit</a></li>
|
122
|
+
|
123
|
+
<li><a href="./VisitList.html">VisitList</a></li>
|
124
|
+
|
125
|
+
<li><a href="./ViziLogFormat.html">ViziLogFormat</a></li>
|
126
|
+
|
127
|
+
<li><a href="./ViziLogParser.html">ViziLogParser</a></li>
|
128
|
+
|
129
|
+
</ul>
|
130
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div id="documentation">
|
138
|
+
<h1 class="class">ViziLogParser</h1>
|
139
|
+
|
140
|
+
<div id="description" class="description">
|
141
|
+
|
142
|
+
<h2>This class handles the parsing of each line in the log file</h2>
|
143
|
+
|
144
|
+
<p>From ... Modified by ...</p>
|
145
|
+
|
146
|
+
</div><!-- description -->
|
147
|
+
|
148
|
+
|
149
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<!-- Constants -->
|
156
|
+
<div id="constants-list" class="section">
|
157
|
+
<h3 class="section-header">Constants</h3>
|
158
|
+
<dl>
|
159
|
+
|
160
|
+
<dt><a name="FIELDNAMES">FIELDNAMES</a></dt>
|
161
|
+
|
162
|
+
<dd class="description"></dd>
|
163
|
+
|
164
|
+
|
165
|
+
<dt><a name="LOG_FORMATS">LOG_FORMATS</a></dt>
|
166
|
+
|
167
|
+
<dd class="description"></dd>
|
168
|
+
|
169
|
+
|
170
|
+
</dl>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<!-- Attributes -->
|
176
|
+
<div id="attribute-method-details" class="method-section section">
|
177
|
+
<h3 class="section-header">Attributes</h3>
|
178
|
+
|
179
|
+
|
180
|
+
<div id="known_formats-attribute-method" class="method-detail">
|
181
|
+
<a name="known_formats"></a>
|
182
|
+
|
183
|
+
<div class="method-heading attribute-method-heading">
|
184
|
+
<span class="method-name">known_formats</span><span
|
185
|
+
class="attribute-access-type">[R]</span>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<div class="method-description">
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
</div>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
</div><!-- attribute-method-details -->
|
196
|
+
|
197
|
+
|
198
|
+
<!-- Methods -->
|
199
|
+
|
200
|
+
<div id="public-class-method-details" class="method-section section">
|
201
|
+
<h3 class="section-header">Public Class Methods</h3>
|
202
|
+
|
203
|
+
|
204
|
+
<div id="new-method" class="method-detail ">
|
205
|
+
<a name="method-c-new"></a>
|
206
|
+
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<span class="method-name">new</span><span
|
210
|
+
class="method-args">(drop_ips, spider_ips, spider_names, page_extensions, homepage, accept_only_homepage, hostname, drop_refers_by_hostname)</span>
|
211
|
+
<span class="method-click-advice">click to toggle source</span>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
|
215
|
+
<div class="method-description">
|
216
|
+
|
217
|
+
<p>@@log = ActiveRecord::Base.logger</p>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<div class="method-source-code" id="new-source">
|
222
|
+
<pre>
|
223
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 114</span>
|
224
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">drop_ips</span>, <span class="ruby-identifier">spider_ips</span>, <span class="ruby-identifier">spider_names</span>, <span class="ruby-identifier">page_extensions</span>, <span class="ruby-identifier">homepage</span>, <span class="ruby-identifier">accept_only_homepage</span>, <span class="ruby-identifier">hostname</span>, <span class="ruby-identifier">drop_refers_by_hostname</span>)
|
225
|
+
<span class="ruby-ivar">@drops</span> = <span class="ruby-identifier">drop_ips</span>
|
226
|
+
<span class="ruby-ivar">@sips</span> = <span class="ruby-identifier">spider_ips</span>
|
227
|
+
<span class="ruby-ivar">@snames</span> = <span class="ruby-identifier">spider_names</span>
|
228
|
+
<span class="ruby-ivar">@page_extensions</span> = <span class="ruby-identifier">page_extensions</span>
|
229
|
+
<span class="ruby-ivar">@homepage</span> = <span class="ruby-identifier">homepage</span>
|
230
|
+
<span class="ruby-ivar">@accept_only_homepage</span> = <span class="ruby-identifier">accept_only_homepage</span>
|
231
|
+
<span class="ruby-ivar">@hostname</span> = <span class="ruby-identifier">hostname</span>
|
232
|
+
<span class="ruby-ivar">@drop_refers_by_hostname</span> = <span class="ruby-identifier">drop_refers_by_hostname</span>
|
233
|
+
<span class="ruby-ivar">@log_format</span> = []
|
234
|
+
<span class="ruby-identifier">initialize_known_formats</span>
|
235
|
+
<span class="ruby-ivar">@parselog</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'./log/parse.log'</span>,<span class="ruby-identifier">shift_age</span> = <span class="ruby-string">'weekly'</span>)
|
236
|
+
<span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>
|
237
|
+
<span class="ruby-keyword">end</span></pre>
|
238
|
+
</div><!-- new-source -->
|
239
|
+
|
240
|
+
</div>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
</div><!-- new-method -->
|
246
|
+
|
247
|
+
|
248
|
+
</div><!-- public-class-method-details -->
|
249
|
+
|
250
|
+
<div id="public-instance-method-details" class="method-section section">
|
251
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
252
|
+
|
253
|
+
|
254
|
+
<div id="build_format-method" class="method-detail ">
|
255
|
+
<a name="method-i-build_format"></a>
|
256
|
+
|
257
|
+
|
258
|
+
<div class="method-heading">
|
259
|
+
<span class="method-name">build_format</span><span
|
260
|
+
class="method-args">(line)</span>
|
261
|
+
<span class="method-click-advice">click to toggle source</span>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
|
265
|
+
<div class="method-description">
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<div class="method-source-code" id="build_format-source">
|
272
|
+
<pre>
|
273
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 147</span>
|
274
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">build_format</span>(<span class="ruby-identifier">line</span>)
|
275
|
+
<span class="ruby-identifier">fields</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)
|
276
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-value">1</span>
|
277
|
+
<span class="ruby-ivar">@format</span> = <span class="ruby-string">""</span>
|
278
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">fields</span>.<span class="ruby-identifier">length</span>
|
279
|
+
<span class="ruby-ivar">@format</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"%"</span><span class="ruby-operator">+</span><span class="ruby-constant">FIELDNAMES</span>[<span class="ruby-identifier">fields</span>[<span class="ruby-identifier">i</span>]]<span class="ruby-operator">+</span><span class="ruby-string">" "</span>
|
280
|
+
<span class="ruby-comment"># p log_format
|
281
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
282
|
+
<span class="ruby-keyword">end</span>
|
283
|
+
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@format</span>
|
284
|
+
<span class="ruby-keyword">end</span></pre>
|
285
|
+
</div><!-- build_format-source -->
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
</div><!-- build_format-method -->
|
293
|
+
|
294
|
+
|
295
|
+
<div id="check_format-method" class="method-detail ">
|
296
|
+
<a name="method-i-check_format"></a>
|
297
|
+
|
298
|
+
|
299
|
+
<div class="method-heading">
|
300
|
+
<span class="method-name">check_format</span><span
|
301
|
+
class="method-args">(line)</span>
|
302
|
+
<span class="method-click-advice">click to toggle source</span>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
|
306
|
+
<div class="method-description">
|
307
|
+
|
308
|
+
<p>Checks which standard the log file (well one line) is Automatically checks
|
309
|
+
for most complex (longest) regex first..</p>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
<div class="method-source-code" id="check_format-source">
|
314
|
+
<pre>
|
315
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 140</span>
|
316
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">check_format</span>(<span class="ruby-identifier">line</span>)
|
317
|
+
<span class="ruby-ivar">@known_formats</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">log_format</span><span class="ruby-operator">|</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>.<span class="ruby-identifier">source</span>.<span class="ruby-identifier">size</span> }.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">log_format</span><span class="ruby-operator">|</span>
|
318
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>)
|
319
|
+
}
|
320
|
+
<span class="ruby-keyword">return</span> <span class="ruby-value">:unknown</span>
|
321
|
+
<span class="ruby-keyword">end</span></pre>
|
322
|
+
</div><!-- check_format-source -->
|
323
|
+
|
324
|
+
</div>
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
</div><!-- check_format-method -->
|
330
|
+
|
331
|
+
|
332
|
+
<div id="initialize_known_formats-method" class="method-detail ">
|
333
|
+
<a name="method-i-initialize_known_formats"></a>
|
334
|
+
|
335
|
+
|
336
|
+
<div class="method-heading">
|
337
|
+
<span class="method-name">initialize_known_formats</span><span
|
338
|
+
class="method-args">()</span>
|
339
|
+
<span class="method-click-advice">click to toggle source</span>
|
340
|
+
</div>
|
341
|
+
|
342
|
+
|
343
|
+
<div class="method-description">
|
344
|
+
|
345
|
+
<p>processes the format string into symbols and test regex and saves using
|
346
|
+
LogFormat class</p>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
<div class="method-source-code" id="initialize_known_formats-source">
|
351
|
+
<pre>
|
352
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 131</span>
|
353
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize_known_formats</span>
|
354
|
+
<span class="ruby-ivar">@known_formats</span> = {}
|
355
|
+
<span class="ruby-constant">LOG_FORMATS</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
|
356
|
+
<span class="ruby-ivar">@known_formats</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-constant">ViziLogFormat</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>)
|
357
|
+
<span class="ruby-keyword">end</span>
|
358
|
+
<span class="ruby-keyword">end</span></pre>
|
359
|
+
</div><!-- initialize_known_formats-source -->
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
</div><!-- initialize_known_formats-method -->
|
367
|
+
|
368
|
+
|
369
|
+
<div id="match_partial-method" class="method-detail ">
|
370
|
+
<a name="method-i-match_partial"></a>
|
371
|
+
|
372
|
+
|
373
|
+
<div class="method-heading">
|
374
|
+
<span class="method-name">match_partial</span><span
|
375
|
+
class="method-args">(field, fldarray)</span>
|
376
|
+
<span class="method-click-advice">click to toggle source</span>
|
377
|
+
</div>
|
378
|
+
|
379
|
+
|
380
|
+
<div class="method-description">
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
<div class="method-source-code" id="match_partial-source">
|
387
|
+
<pre>
|
388
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 159</span>
|
389
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">match_partial</span> (<span class="ruby-identifier">field</span>, <span class="ruby-identifier">fldarray</span>)
|
390
|
+
<span class="ruby-identifier">hit</span> = <span class="ruby-keyword">nil</span>
|
391
|
+
<span class="ruby-identifier">hit</span> = <span class="ruby-identifier">fldarray</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">field</span>)
|
392
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">hit</span>
|
393
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
|
394
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">k</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">fldarray</span>.<span class="ruby-identifier">length</span>
|
395
|
+
<span class="ruby-identifier">hit</span> = <span class="ruby-identifier">field</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">fldarray</span>)
|
396
|
+
<span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">hit</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
397
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
398
|
+
<span class="ruby-keyword">end</span>
|
399
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">hit</span>
|
400
|
+
<span class="ruby-keyword">end</span></pre>
|
401
|
+
</div><!-- match_partial-source -->
|
402
|
+
|
403
|
+
</div>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
</div><!-- match_partial-method -->
|
409
|
+
|
410
|
+
|
411
|
+
<div id="parse_line-method" class="method-detail ">
|
412
|
+
<a name="method-i-parse_line"></a>
|
413
|
+
|
414
|
+
|
415
|
+
<div class="method-heading">
|
416
|
+
<span class="method-name">parse_line</span><span
|
417
|
+
class="method-args">(line, logformat)</span>
|
418
|
+
<span class="method-click-advice">click to toggle source</span>
|
419
|
+
</div>
|
420
|
+
|
421
|
+
|
422
|
+
<div class="method-description">
|
423
|
+
|
424
|
+
<p>apache files ... regex the file to determine logformat name IIS files ...
|
425
|
+
parse the fields string to determine the file contents</p>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
<div class="method-source-code" id="parse_line-source">
|
430
|
+
<pre>
|
431
|
+
<span class="ruby-comment"># File lib/vizi/parser.rb, line 174</span>
|
432
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_line</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">logformat</span>)
|
433
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">logformat</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
434
|
+
<span class="ruby-identifier">log_format</span> = <span class="ruby-identifier">logformat</span> <span class="ruby-comment"># get log_format string
|
435
|
+
<span class="ruby-ivar">@format_name</span> = <span class="ruby-string">"temp"</span>
|
436
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)
|
437
|
+
<span class="ruby-keyword">else</span>
|
438
|
+
<span class="ruby-ivar">@format_name</span> = <span class="ruby-identifier">check_format</span>(<span class="ruby-identifier">line</span>) <span class="ruby-comment"># look for matching formats, check each time
|
439
|
+
<span class="ruby-identifier">log_format</span> = <span class="ruby-ivar">@known_formats</span>[<span class="ruby-ivar">@format_name</span>] <span class="ruby-comment"># found a matched format
|
440
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">!~</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>
|
441
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>).<span class="ruby-identifier">flatten</span>
|
442
|
+
<span class="ruby-keyword">end</span>
|
443
|
+
<span class="ruby-identifier">parsed_data</span> = {}
|
444
|
+
<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_symbols</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
445
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_symbols</span>[<span class="ruby-identifier">i</span>]] = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">i</span>] <span class="ruby-comment"># load data for each format_symbol
|
446
|
+
<span class="ruby-keyword">end</span>
|
447
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>]
|
448
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>][<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>]
|
449
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">":"</span>,<span class="ruby-string">" "</span>)
|
450
|
+
<span class="ruby-keyword">end</span>
|
451
|
+
<span class="ruby-comment"># Add ip as domain if we don't have a domain (virtual host)
|
452
|
+
<span class="ruby-comment"># Assumes we always have an ip
|
453
|
+
<span class="ruby-comment"># parsed_data[:domain] = parsed_data[:ip] unless parsed_data[:domain] ##<<-- don't know this
|
454
|
+
<span class="ruby-comment"># parsed_data[:format_name] = @format_name
|
455
|
+
|
456
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformatname</span>] = <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span>
|
457
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-identifier">logformat</span>
|
458
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">"H"</span> <span class="ruby-comment"># set default visitor type (H)uman
|
459
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"V"</span> <span class="ruby-comment"># linetype is (V)isitors
|
460
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"C"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># reset if a comment line
|
461
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">"w3c_f"</span> <span class="ruby-comment"># IIS file name ... generic
|
462
|
+
<span class="ruby-ivar">@format</span> = <span class="ruby-identifier">build_format</span>(<span class="ruby-identifier">line</span>) <span class="ruby-comment"># parse fields to get log_format
|
463
|
+
<span class="ruby-identifier">temp_format</span> = <span class="ruby-constant">ViziLogFormat</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:temp</span>, <span class="ruby-ivar">@format</span>) <span class="ruby-comment"># create temp format
|
464
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-identifier">temp_format</span> <span class="ruby-comment"># shuttle the log_format object
|
465
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformatname</span>] = <span class="ruby-string">"temp"</span> <span class="ruby-comment"># change the name
|
466
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"F"</span> <span class="ruby-comment"># linetype to (F)ield list
|
467
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">"-"</span> <span class="ruby-comment"># visitor type not relevant
|
468
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">"w3c_c"</span> <span class="ruby-comment"># IIS file name ... comments
|
469
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"C"</span> <span class="ruby-comment"># linetype is (C)omment
|
470
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">"-"</span>
|
471
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"C"</span>
|
472
|
+
<span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">warn</span> <span class="ruby-identifier">line</span>
|
473
|
+
<span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">"Found comment lines embedded in the log file ... resetting to nil"</span>
|
474
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-keyword">nil</span>
|
475
|
+
<span class="ruby-keyword">else</span> <span class="ruby-comment"># parsing the field names
|
476
|
+
|
477
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datestring</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
478
|
+
<span class="ruby-identifier">dt</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datestring</span>]<span class="ruby-operator">+</span><span class="ruby-string">" "</span><span class="ruby-operator">+</span><span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:timestring</span>])
|
479
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datetime</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">year</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">month</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">day</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">hour</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">min</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">sec</span>)
|
480
|
+
<span class="ruby-keyword">end</span>
|
481
|
+
|
482
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
483
|
+
<span class="ruby-identifier">dt</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>])
|
484
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datetime</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">year</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">month</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">day</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">hour</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">min</span>,<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">sec</span>)
|
485
|
+
<span class="ruby-keyword">end</span>
|
486
|
+
|
487
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:request</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
488
|
+
<span class="ruby-identifier">splitrequest</span> = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:request</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-string">"/"</span>,<span class="ruby-string">" "</span>).<span class="ruby-identifier">split</span>
|
489
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>] = <span class="ruby-identifier">splitrequest</span>[<span class="ruby-value">1</span>]
|
490
|
+
<span class="ruby-keyword">end</span>
|
491
|
+
|
492
|
+
<span class="ruby-comment"># Now classify records based on logger rules ...
|
493
|
+
|
494
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">false</span>
|
495
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@accept_only_homepage</span>
|
496
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@homepage</span>) <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
497
|
+
<span class="ruby-keyword">else</span>
|
498
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">match_partial</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>], <span class="ruby-ivar">@page_extensions</span>)
|
499
|
+
<span class="ruby-keyword">end</span>
|
500
|
+
|
501
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"D"</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@drops</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>])
|
502
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">"S"</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sips</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>])
|
503
|
+
|
504
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:user_agent</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
505
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">"S"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">match_partial</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:user_agent</span>], <span class="ruby-ivar">@snames</span>)
|
506
|
+
<span class="ruby-keyword">end</span>
|
507
|
+
|
508
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@drop_refers_by_hostname</span>
|
509
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"D"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>].<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@hostname</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
510
|
+
<span class="ruby-keyword">end</span>
|
511
|
+
|
512
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
513
|
+
<span class="ruby-identifier">y</span> = (<span class="ruby-regexp">/(search\?\S*?[pq])=(\S*?)(&)/</span>).<span class="ruby-identifier">match</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>])
|
514
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_searchphrase</span>] = <span class="ruby-identifier">y</span>[<span class="ruby-value">2</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">y</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
515
|
+
<span class="ruby-comment">#p parsed_data[:ip] if y != nil
|
516
|
+
<span class="ruby-comment">#p parsed_data[:p_searchphrase] if y != nil
|
517
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@drop_refers_by_hostname</span>
|
518
|
+
<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">"D"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>].<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@hostname</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
519
|
+
<span class="ruby-keyword">end</span>
|
520
|
+
<span class="ruby-keyword">end</span>
|
521
|
+
|
522
|
+
<span class="ruby-keyword">end</span>
|
523
|
+
<span class="ruby-comment"># p parsed_data
|
524
|
+
<span class="ruby-identifier">parsed_data</span>
|
525
|
+
<span class="ruby-keyword">end</span></pre>
|
526
|
+
</div><!-- parse_line-source -->
|
527
|
+
|
528
|
+
</div>
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
</div><!-- parse_line-method -->
|
534
|
+
|
535
|
+
|
536
|
+
</div><!-- public-instance-method-details -->
|
537
|
+
|
538
|
+
</div><!-- 5Buntitled-5D -->
|
539
|
+
|
540
|
+
|
541
|
+
</div><!-- documentation -->
|
542
|
+
|
543
|
+
<div id="validator-badges">
|
544
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
545
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
546
|
+
Rdoc Generator</a> 2</small>.</p>
|
547
|
+
</div>
|
548
|
+
|
549
|
+
</body>
|
550
|
+
</html>
|
551
|
+
|