summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-29 19:50:30 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-29 19:50:30 +0200
commit6ad1f8f479da97b4cf7eb17b05050593883dde49 (patch)
tree2c92d77b1abb70bc2c47c41f21bae6835d91adeb
parentacb76cca1c0bdedc811d7eeed1b2392b692cdf50 (diff)
downloadluaotfload-6ad1f8f479da97b4cf7eb17b05050593883dde49.tar.gz
use unbuffered stdout
-rw-r--r--luaotfload-database.lua5
-rw-r--r--luaotfload-override.lua64
2 files changed, 56 insertions, 13 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index aba1921..813a471 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -285,8 +285,9 @@ load_names = function (dry_run)
1000*(os.gettimeofday()-starttime))
else
report("both", 0, "db",
- [[Font names database not found, generating new one.
- This can take several minutes; please be patient.]])
+ [[Font names database not found, generating new one.]])
+ report("both", 0, "db",
+ [[This can take several minutes; please be patient.]])
data = update_names(fontnames_init(false), nil, dry_run)
local success = save_names(data)
if not success then
diff --git a/luaotfload-override.lua b/luaotfload-override.lua
index 5e642e4..caf3627 100644
--- a/luaotfload-override.lua
+++ b/luaotfload-override.lua
@@ -1,17 +1,30 @@
if not modules then modules = { } end modules ['luat-ovr'] = {
- version = 2.2,
+ version = 2.3,
comment = "companion to luatex-*.tex",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2"
}
-local module_name = "luaotfload"
+--[[doc--
+The logging system is slow in general, as we always have the function
+call overhead even if we aren’t going to output anything. On the other
+hand, the more efficient approach followed by Context isn’t an option
+because we lack a user interface to toggle per-subsystem tracing.
+--doc]]--
+
+local module_name = "luaotfload"
-local texiowrite_nl = texio.write_nl
-local stringformat = string.format
-local tableconcat = table.concat
-local type = type
+local select = select
+local stringformat = string.format
+local tableconcat = table.concat
+local texiowrite_nl = texio.write_nl
+local texiowrite = texio.write
+local type = type
+
+local texio_write_nl = texio.write_nl
+local texio_write = texio.write
+local iowrite = io.write
--[[doc--
We recreate the verbosity levels previously implemented in font-nms:
@@ -65,11 +78,40 @@ local log = function (category, fmt, ...)
texiowrite_nl(logout, tableconcat(res))
end
-local stdout = function (category, fmt, ...)
- local res = { module_name, " |" }
- if category then res[#res+1] = " " .. category end
- if fmt then res[#res+1] = ": " .. stringformat(fmt, ...) end
- texiowrite_nl(tableconcat(res))
+--- with faux db update with maximum verbosity:
+---
+--- --------- --------
+--- buffering time (s)
+--- --------- --------
+--- full 4.12
+--- line 4.20
+--- none 4.39
+--- --------- --------
+---
+
+io.stdout:setvbuf "no"
+io.stderr:setvbuf "no"
+
+local writeln
+if tex and (tex.jobname or tex.formatname) then
+ --- TeX
+ writeln = texiowrite_nl
+else
+ --- Lua interpreter
+ writeln = function (str)
+ iowrite(str)
+ iowrite "\n"
+ end
+end
+
+stdout = function (category, ...)
+ local res = { module_name, "|", category, ":" }
+ if select("#", ...) == 1 then
+ res[#res+1] = select(1, ...) -- around 30% faster than unpack()
+ else
+ res[#res+1] = stringformat(...)
+ end
+ writeln(tableconcat(res, " "))
end
--- at default (zero), we aim to be quiet