diff options
Diffstat (limited to 'src/luaotfload-log.lua')
-rw-r--r-- | src/luaotfload-log.lua | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/luaotfload-log.lua b/src/luaotfload-log.lua index 5b2f1f3..ab38ffa 100644 --- a/src/luaotfload-log.lua +++ b/src/luaotfload-log.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ["luaotfload-log"] = { - version = "2.7", + version = "2.8", comment = "companion to Luaotfload", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", @@ -14,6 +14,7 @@ because we lack a user interface to toggle per-subsystem tracing. --doc]]-- local module_name = "luaotfload" --- prefix for messages +local debug = debug luaotfload = luaotfload or { } luaotfload.log = luaotfload.log or { } @@ -132,10 +133,33 @@ end log.set_logout = set_logout +local format_error_handler +if debug then + local debugtraceback = debug.traceback + format_error_handler = function (err) + print "" + print (stringformat ("luaotfload error: %q", err)) + print (stringformat ("Lua interpreter %s", debugtraceback ())) + print "" + end +else + format_error_handler = function (err) + print "" + print (stringformat ("luaotfload error: %q", err)) + print "Lua debug module not available; please enable for a backtrace" + print "" + end +end + local basic_logger = function (category, fmt, ...) - local res = { module_name, "|", category, ":" } + local res = { module_name, "|", category or "UNKNOWN", ":" } if fmt then - res [#res + 1] = stringformat (fmt, ...) + local ok, val = xpcall (stringformat, format_error_handler, fmt, ...) + if ok then + res [#res + 1] = val + else + res [#res + 1] = stringformat ("ERROR: %q", val) + end end texiowrite_nl (logout, tableconcat(res, " ")) end @@ -354,4 +378,4 @@ local texioreporter = function (message) end texio.reporter = texioreporter - +--- vim:shiftwidth=4:expandtab:ft=lua |