summaryrefslogtreecommitdiff
path: root/tex/context/base/trac-log.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/trac-log.lua')
-rw-r--r--tex/context/base/trac-log.lua41
1 files changed, 36 insertions, 5 deletions
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index 1f2520130..0ae5d87e3 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -68,13 +68,14 @@ local write_nl, write = texio and texio.write_nl or print, texio and texio.write
local format, gmatch, find = string.format, string.gmatch, string.find
local concat, insert, remove = table.concat, table.insert, table.remove
local topattern = string.topattern
-local texcount = tex and tex.count
local next, type, select = next, type, select
local utfchar = utf.char
local setmetatableindex = table.setmetatableindex
local formatters = string.formatters
+local texgetcount = tex and tex.getcount
+
--[[ldx--
<p>This is a prelude to a more extensive logging module. We no longer
provide <l n='xml'/> based logging as parsing is relatively easy anyway.</p>
@@ -129,7 +130,7 @@ setmetatableindex(logs, function(t,k) t[k] = ignore ; return ignore end)
local report, subreport, status, settarget, setformats, settranslations
-local direct, subdirect, writer, pushtarget, poptarget
+local direct, subdirect, writer, pushtarget, poptarget, setlogfile
if tex and (tex.jobname or tex.formatname) then
@@ -270,11 +271,15 @@ if tex and (tex.jobname or tex.formatname) then
translations = t
end
+ setlogfile = ignore
+
else
logs.flush = ignore
- writer = write_nl
+ writer = function(s)
+ write_nl(s)
+ end
newline = function()
write_nl("\n")
@@ -334,6 +339,29 @@ else
setformats = ignore
settranslations = ignore
+ local f_timed = formatters["[%S] "]
+
+ setlogfile = function(name,keepopen)
+ if name and name ~= "" then
+ local localtime = os.localtime
+ local writeline = write_nl
+ if keepopen then
+ local f = io.open(name,"ab")
+ write_nl = function(s)
+ writeline(s)
+ f:write(f_timed(localtime()),s,"\n")
+ end
+ else
+ write_nl = function(s)
+ writeline(s)
+ local f = io.open(name,"ab")
+ f:write(f_timed(localtime()),s,"\n")
+ f:close()
+ end
+ end
+ end
+ end
+
end
logs.report = report
@@ -345,6 +373,8 @@ logs.poptarget = poptarget
logs.setformats = setformats
logs.settranslations = settranslations
+logs.setlogfile = setlogfile
+
logs.direct = direct
logs.subdirect = subdirect
logs.writer = writer
@@ -529,8 +559,9 @@ local report_pages = logs.reporter("pages") -- not needed but saves checking whe
local real, user, sub
function logs.start_page_number()
- real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
--- real, user, sub = 0, 0, 0
+ real = texgetcount("realpageno")
+ user = texgetcount("userpageno")
+ sub = texgetcount("subpageno")
end
local timing = false