]>
Commit | Line | Data |
---|---|---|
5b8ace12 | 1 | #!/usr/bin/perl -w |
df3cec97 | 2 | # |
4ac4a490 | 3 | # * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
df3cec97 AJ |
4 | # * |
5 | # * Squid software is distributed under GPLv2+ license and includes | |
6 | # * contributions from numerous individuals and organizations. | |
7 | # * Please see the COPYING and CONTRIBUTORS files for details. | |
8 | # | |
5b8ace12 AJ |
9 | |
10 | # | |
11 | # This is a simple module which takes in a Squid format logfile line and breaks it up into | |
12 | # a perl hash. | |
13 | # | |
14 | # I'm not going to pretend this is 100% accurate just yet but its a start. | |
15 | # I'm hoping that by placing it into the public domain it (and the other stuff | |
16 | # I sneak in here) will be debugged and improved by others. | |
17 | # | |
18 | # Adrian Chadd <adrian@squid-cache.org> | |
19 | # | |
20 | # $Id: ParseLog.pm,v 1.1 2007/01/24 06:50:35 adrian Exp $ | |
21 | # | |
22 | ||
23 | use strict; | |
24 | ||
25 | package Squid::ParseLog; | |
26 | ||
27 | sub parse($) { | |
28 | my ($line) = @_; | |
29 | my (%t); | |
30 | chomp $line; | |
31 | ||
32 | $line =~ m/^(.*?) (\d+?) (.*?) (.*?)\/(\d+?) (\d+?) (.*?) (.*?) (.*?) (.*?)\/(.*?) (.*)$/; | |
33 | ||
34 | $t{"timestamp"} = $1; | |
35 | $t{"reqtime"} = $2; | |
36 | $t{"clientip"} = $3; | |
37 | $t{"code"} = $4; | |
38 | $t{"httpcode"} = $5; | |
39 | $t{"size"} = $6; | |
40 | $t{"method"} = $7; | |
41 | $t{"url"} = $8; | |
42 | $t{"username"} = $9; | |
43 | $t{"fwdcode"} = $10; | |
44 | $t{"fwdip"} = $11; | |
45 | $t{"mime"} = $12; | |
46 | ||
47 | return \%t; | |
48 | } | |
49 | ||
50 | 1; |