summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/trac-log.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/trac-log.lua')
-rw-r--r--tex/context/base/mkiv/trac-log.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/tex/context/base/mkiv/trac-log.lua b/tex/context/base/mkiv/trac-log.lua
index b35e53f2e..be6fff488 100644
--- a/tex/context/base/mkiv/trac-log.lua
+++ b/tex/context/base/mkiv/trac-log.lua
@@ -114,20 +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
- variant = "ansilog"
+ if ansisupported("ansilog") then
+ variant = "ansilog"
+ end
break
end
end
@@ -376,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
@@ -519,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
@@ -954,6 +974,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