summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-01-19 10:07:14 +0000
committerTed Trask <ttrask01@yahoo.com>2010-01-19 10:07:14 +0000
commitce67fd36c7f7bff00acb95598394f71bbcd33836 (patch)
tree60780d02339f22ea75617f14a334af503d0ec59c
parent8cdd9167bd221394615546b4263634face6b7d93 (diff)
downloadacf-weblog-ce67fd36c7f7bff00acb95598394f71bbcd33836.tar.bz2
acf-weblog-ce67fd36c7f7bff00acb95598394f71bbcd33836.tar.xz
Bug fix for malformed squid log.
-rw-r--r--weblog-model.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/weblog-model.lua b/weblog-model.lua
index d29c096..460a8f5 100644
--- a/weblog-model.lua
+++ b/weblog-model.lua
@@ -181,7 +181,7 @@ end
local importsquidlog = function(entry, sourcename)
if entry then
local sql = string.format("INSERT INTO weblog VALUES ('%s', '%s', '%s', '%s', '%s', '%s')",
- escape(sourcename), escape(entry.clientip), escape(entry.clientuserid:lower()),
+ escape(sourcename), escape(entry.clientip), escape(entry.clientuserid):lower(),
escape(entry.logdatetime), escape(entry.URL), escape(entry.bytes))
local res = assert (con:execute(sql))
end
@@ -562,14 +562,14 @@ local function parsesquidlog(line)
local logentry = {logdatetime=words[1],
elapsed=words[2],
clientip=words[3],
- code=string.match(words[4], "^[^/]*"),
- status=string.match(words[4], "[^/]*$"),
+ code=string.match(words[4] or "", "^[^/]*"),
+ status=string.match(words[4] or "", "[^/]*$"),
bytes=words[5],
method=words[6],
URL=words[7],
clientuserid=words[8],
- peerstatus=string.match(words[9], "^[^/]*"),
- peerhost=string.match(words[9], "[^/]*$")}
+ peerstatus=string.match(words[9] or "", "^[^/]*"),
+ peerhost=string.match(words[9] or "", "[^/]*$")}
logentry.logdatetime = os.date("%Y-%m-%d %H:%M:%S", logentry.logdatetime)..string.match(logentry.logdatetime, "%..*")
-- Don't care about local requests (from DG)