diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/trac-log.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/trac-log.lua | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua index e76c9f6849e..bb154067f70 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua @@ -114,17 +114,34 @@ local direct, subdirect, writer, pushtarget, poptarget, setlogfile, settimedlog, -- we don't want this overhead for single messages (not that there are that -- many; we could have a special weak table) +local function ansisupported(specification) + if specification ~= "ansi" and specification ~= "ansilog" then + return false + elseif os and os.enableansi then + return os.enableansi() + else + return false + end +end + if runningtex and texio then if texio.setescape then texio.setescape(0) -- or (false) end - if arg then + if arg and ansisupported then -- we're don't have environment.arguments yet for k, v in next, arg do -- k can be negative ! if v == "--ansi" or v == "--c:ansi" then - variant = "ansi" + if ansisupported("ansi") then + variant = "ansi" + end + break + elseif v == "--ansilog" or v == "--c:ansilog" then + if ansisupported("ansilog") then + variant = "ansilog" + end break end end @@ -246,6 +263,11 @@ if runningtex and texio then } } + variants.ansilog = { + formats = variants.ansi.formats, + targets = variants.default.targets, + } + logs.flush = io.flush writer = function(...) @@ -368,6 +390,9 @@ if runningtex and texio then t = specification.targets f = specification.formats or specification else + if not ansisupported(specification) then + specification = "default" + end local v = variants[specification] if v then t = v.targets @@ -394,8 +419,8 @@ if runningtex and texio then subdirect_nop = f.subdirect_nop status_yes = f.status_yes status_nop = f.status_nop - if variant == "ansi" then - useluawrites() -- because tex escapes ^^ + if variant == "ansi" or variant == "ansilog" then + useluawrites() -- because tex escapes ^^, not needed in lmtx end settarget(whereto) end @@ -511,6 +536,9 @@ else if type(specification) == "table" then f = specification.formats or specification else + if not ansisupported(specification) then + specification = "default" + end local v = variants[specification] if v then f = v.formats @@ -817,38 +845,6 @@ local nesting = 0 local verbose = false local hasscheme = url.hasscheme -function logs.show_open(name) - -- if hasscheme(name) ~= "virtual" then - -- if verbose then - -- nesting = nesting + 1 - -- report_files("level %s, opening %s",nesting,name) - -- else - -- write(formatters["(%s"](name)) -- tex adds a space - -- end - -- end -end - -function logs.show_close(name) - -- if hasscheme(name) ~= "virtual" then - -- if verbose then - -- report_files("level %s, closing %s",nesting,name) - -- nesting = nesting - 1 - -- else - -- write(")") -- tex adds a space - -- end - -- end -end - -function logs.show_load(name) - -- if hasscheme(name) ~= "virtual" then - -- if verbose then - -- report_files("level %s, loading %s",nesting+1,name) - -- else - -- write(formatters["(%s)"](name)) - -- end - -- end -end - -- there may be scripts out there using this: local simple = logs.reporter("comment") @@ -946,6 +942,15 @@ logs.reporters = reporters logs.exporters = exporters function logs.application(t) + -- + local arguments = environment and environment.arguments + if arguments then + local ansi = arguments.ansi or arguments.ansilog + if ansi then + logs.setformatters(arguments.ansi and "ansi" or "ansilog") + end + end + -- t.name = t.name or "unknown" t.banner = t.banner t.moreinfo = moreinfo @@ -1039,8 +1044,8 @@ end -- this is somewhat slower but prevents out-of-order messages when print is mixed -- with texio.write -io.stdout:setvbuf('no') -io.stderr:setvbuf('no') +-- io.stdout:setvbuf('no') +-- io.stderr:setvbuf('no') -- windows: > nul 2>&1 -- unix : > null 2>&1 |