summaryrefslogtreecommitdiff
path: root/otfl-luat-ovr.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-15 00:57:10 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-15 00:57:10 +0200
commit5a8c4657de6b599e1897d8ac4e685264e0ac0587 (patch)
tree4475fa4bd49a9cf5bda07c715797377d25e182eb /otfl-luat-ovr.lua
parent25444ac8cd48cd5ad7ed32bfcc9a0a1314e2223a (diff)
downloadluaotfload-5a8c4657de6b599e1897d8ac4e685264e0ac0587.tar.gz
unify logging
Diffstat (limited to 'otfl-luat-ovr.lua')
-rw-r--r--otfl-luat-ovr.lua52
1 files changed, 36 insertions, 16 deletions
diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua
index 63ad6a7..0657bbe 100644
--- a/otfl-luat-ovr.lua
+++ b/otfl-luat-ovr.lua
@@ -12,8 +12,8 @@ local module_name = "luaotfload"
local texiowrite_nl = texio.write_nl
local stringformat = string.format
local tableconcat = table.concat
-local ioflush = io.flush
local dummyfunction = function() end
+local type = type
--[[doc--
We recreate the verbosity levels previously implemented in font-nms:
@@ -47,24 +47,44 @@ function logs.report(category,fmt,...)
end
end
-function logs.info(category,fmt,...)
- if fmt then
- texiowrite_nl(stringformat("%s | %s: %s",module_name,category,stringformat(fmt,...)))
- elseif category then
- texiowrite_nl(stringformat("%s | %s",module_name,category))
- else
- texiowrite_nl(stringformat("%s |",module_name))
- end
- ioflush()
-end
-
-logs.names_loading = function (category, fmt, ...)
- if loglevel > 1 then
+logs.names_search = function (category, fmt, ...)
+ if loglevel > 2 then
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))
- ioflush()
+ texiowrite_nl("log", tableconcat(res))
+ end
+end
+
+
+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("log", 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
+
+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
end