summaryrefslogtreecommitdiff
path: root/otfl-luat-ovr.lua
diff options
context:
space:
mode:
authorElie Roux <elie.roux@telecom-bretagne.eu>2013-04-18 18:09:20 +0200
committerElie Roux <elie.roux@telecom-bretagne.eu>2013-04-18 18:09:20 +0200
commita9510469b60edeceedf72811e7737ea0f3c56dc5 (patch)
tree5c7a80ce3a0c2f1d22c12bff36f84355df554c46 /otfl-luat-ovr.lua
parente67643a60422ed265dc5ad8955a83140598385f1 (diff)
parentb0c22678d1f776f991ffef67694451b8bb5f9e20 (diff)
downloadluaotfload-a9510469b60edeceedf72811e7737ea0f3c56dc5.tar.gz
Merge branch 'experimental' of phi-gamma/luaotfload into phi-gamma-experimental
Conflicts: mkluatexfontdb.lua otfl-basics-gen.lua
Diffstat (limited to 'otfl-luat-ovr.lua')
-rw-r--r--otfl-luat-ovr.lua84
1 files changed, 64 insertions, 20 deletions
diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua
index 63a9e19..bd04eeb 100644
--- a/otfl-luat-ovr.lua
+++ b/otfl-luat-ovr.lua
@@ -7,30 +7,74 @@ if not modules then modules = { } end modules ['luat-ovr'] = {
}
-local write_nl, format, name = texio.write_nl, string.format, "luaotfload"
-local dummyfunction = function() end
+local module_name = "luaotfload"
-callbacks = {
- register = dummyfunction,
-}
+local texiowrite_nl = texio.write_nl
+local stringformat = string.format
+local tableconcat = table.concat
+local type = type
+
+--[[doc--
+We recreate the verbosity levels previously implemented in font-nms:
+
+ ==========================================================
+ lvl arg trace_loading trace_search suppress_output
+ ----------------------------------------------------------
+ (0) -> -q ⊥ ⊥ ⊤
+ (1) -> ∅ ⊥ ⊥ ⊥
+ (2) -> -v ⊤ ⊥ ⊥
+ (>2) -> -vv ⊤ ⊤ ⊥
+ ==========================================================
+
+--doc]]--
+local loglevel = 1 --- default
+local logout = "log"
-function logs.report(category,fmt,...)
- if fmt then
- write_nl('log', format("%s | %s: %s",name,category,format(fmt,...)))
- elseif category then
- write_nl('log', format("%s | %s",name,category))
- else
- write_nl('log', format("%s |",name))
+local set_loglevel = function (n)
+ if type(n) == "number" then
+ loglevel = n
end
end
+logs.set_loglevel = set_loglevel
+
+local set_logout = function (s)
+ if s == "stdout" then
+ logout = "term"
+ --else --- remains “log”
+ end
+end
+
+logs.set_logout = set_logout
+
+local log = 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(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))
+end
-function logs.info(category,fmt,...)
- if fmt then
- write_nl(format("%s | %s: %s",name,category,format(fmt,...)))
- elseif category then
- write_nl(format("%s | %s",name,category))
- else
- write_nl(format("%s |",name))
+local level_ids = { common = 0, loading = 1, search = 2 }
+
+logs.names_report = function (mode, lvl, ...)
+ if type(lvl) == "string" then
+ lvl = level_ids[lvl]
+ end
+ if not lvl then lvl = 0 end
+
+ if loglevel > lvl then
+ if mode == "log" then
+ log (...)
+ else
+ stdout (...)
+ end
end
- io.flush()
end
+
+-- vim:tw=71:sw=4:ts=4:expandtab