From 262ed0ee86af10c83e4878f67c167de9f29188a0 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 17 Oct 2011 13:03:47 +0000 Subject: Added logrotate script for acf.log (cherry picked from commit aa581098ea396d65680e4ccee0db6e323c3c0ba2) --- Makefile | 5 ++++- acf | 10 ++++++++++ lib/viewfunctions.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 acf diff --git a/Makefile b/Makefile index 54ac354..ec1f0af 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,9 @@ DISTPKG=$(P).tar.bz2 SUBDIRS=app lib www EXTRA_DIST=config.mk Makefile README CONF_FILES=acf.conf +LOGROTATE_FILES=acf -DISTFILES=$(EXTRA_DIST) $(CONF_FILES) +DISTFILES=$(EXTRA_DIST) $(CONF_FILES) $(LOGROTATE_FILES) CP=cp TAR=tar @@ -52,6 +53,8 @@ phony+=install install: install-recursive $(CONF_FILES) mkdir -p $(DESTDIR)/etc/acf cp $(CONF_FILES) $(DESTDIR)/etc/acf + mkdir -p $(DESTDIR)/etc/logrotate.d + cp $(LOGROTATE_FILES) $(DESTDIR)/etc/logrotate.d ln -sf /etc/acf/skins $(DESTDIR)/$(wwwdir)/userskins include config.mk diff --git a/acf b/acf new file mode 100644 index 0000000..382f8de --- /dev/null +++ b/acf @@ -0,0 +1,10 @@ +# ACF logrotate script + +/var/log/acf.log { + daily + missingok + copytruncate + rotate 7 + compress + notifempty +} diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua index 5f923f5..67f839b 100644 --- a/lib/viewfunctions.lua +++ b/lib/viewfunctions.lua @@ -20,6 +20,46 @@ function getlabel(myitem, value) return value end +function displayitemcustom(myitem, header_level) + if not myitem then return end + if myitem.type == "group" then + header_level = header_level or 2 + io.write(""..html.html_escape(myitem.label).."") + if myitem.descr then io.write('

' .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "

\n") end + if myitem.errtxt then io.write('

' .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "

\n") end + local seqorder = {} + local order = {} + for name,item in pairs(myitem.value) do + if tonumber(item.seq) then + seqorder[#seqorder+1] = {seq=tonumber(item.seq), name=name} + else + order[#order+1] = name + end + end + table.sort(seqorder, function(a,b) if a.seq ~= b.seq then return a.seq > b.seq else return a.name > b.name end end) + table.sort(order) + for i,val in ipairs(seqorder) do + table.insert(order, 1, val.name) + end + for x,name in ipairs(order) do + if myitem.value[name] then + displayitemcustom(myitem.value[name], tonumber(header_level)+1) + end + end + elseif myitem.type ~= "hidden" then + io.write("" .. html.html_escape(myitem.label) .. "\n") + io.write("
") + io.write(string.gsub(html.html_escape(tostring(myitem.value)), "\n", "
") .. "\n") + if myitem.descr then io.write("

" .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "

\n") end + if myitem.errtxt then io.write("

" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "

\n") end + io.write("
\n") + end +end function displayitem(myitem) if not myitem then return end io.write("