From b1b16d264aa0b6311689cc4b6759dd01ff224ed1 Mon Sep 17 00:00:00 2001
From: onefang
Date: Mon, 1 Jun 2020 15:34:30 +1000
Subject: Don't try to write to a log file we couldn't open.
---
apt-panopticon.lua | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index 16a4b3a..b44843b 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -1194,13 +1194,16 @@ else
end
local combine = function(ip, a)
- if not APT.logOpen(hst, ip) then print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. ip) end
- APT.logFile:write('
Note log lines will be out of order, this is a bunch of other log files combined.
\n')
- for i, f in pairs(a) do
- f = f:sub(9, -1)
- APT.logFile:write('
\n
\n\n')
- for ln in io.lines('results/' .. f) do
- if ln:match('^' .. os.date('!%Y%-%m%-%d ') .. '.*$') then APT.logFile:write(ln .. '\n') end -- %F isn't good enough, coz we have to escape the '-'.
+ if not APT.logOpen(hst, ip) then
+ print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. ip)
+ else
+ APT.logFile:write('Note log lines will be out of order, this is a bunch of other log files combined.
\n')
+ for i, f in pairs(a) do
+ f = f:sub(9, -1)
+ APT.logFile:write('
\n
\n\n')
+ for ln in io.lines('results/' .. f) do
+ if ln:match('^' .. os.date('!%Y%-%m%-%d ') .. '.*$') then APT.logFile:write(ln .. '\n') end -- %F isn't good enough, coz we have to escape the '-'.
+ end
end
end
APT.logPost()
--
cgit v1.1