diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-01-19 10:07:14 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-01-19 10:17:49 +0000 |
commit | 53556f19ca3d2c2162dace83dd89f08f1fc248f3 (patch) | |
tree | 3804fe1f31eb15787bf6b9179a0a88526d1e4dab | |
parent | 5ff4f3a8061cef722b48bf0ad94889a771027f0d (diff) | |
download | acf-weblog-53556f19ca3d2c2162dace83dd89f08f1fc248f3.tar.bz2 acf-weblog-53556f19ca3d2c2162dace83dd89f08f1fc248f3.tar.xz |
Bug fix for malformed squid log.
-rw-r--r-- | weblog-model.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/weblog-model.lua b/weblog-model.lua index 26cdf92..7d71aa5 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 @@ -558,14 +558,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) |