From b85a3646ea13a26b2d8506531d2bdf072db81837 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 11 Apr 2013 00:18:13 +0200 Subject: enable overrides for Context loggers --- otfl-luat-ovr.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'otfl-luat-ovr.lua') diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua index 63a9e19..984dbf5 100644 --- a/otfl-luat-ovr.lua +++ b/otfl-luat-ovr.lua @@ -7,30 +7,31 @@ 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 ioflush = io.flush +local dummyfunction = function() end function logs.report(category,fmt,...) if fmt then - write_nl('log', format("%s | %s: %s",name,category,format(fmt,...))) + texiowrite_nl('log', stringformat("%s | %s: %s",module_name,category,stringformat(fmt,...))) elseif category then - write_nl('log', format("%s | %s",name,category)) + texiowrite_nl('log', stringformat("%s | %s",module_name,category)) else - write_nl('log', format("%s |",name)) + texiowrite_nl('log', stringformat("%s |",module_name)) end end function logs.info(category,fmt,...) if fmt then - write_nl(format("%s | %s: %s",name,category,format(fmt,...))) + texiowrite_nl(stringformat("%s | %s: %s",module_name,category,stringformat(fmt,...))) elseif category then - write_nl(format("%s | %s",name,category)) + texiowrite_nl(stringformat("%s | %s",module_name,category)) else - write_nl(format("%s |",name)) + texiowrite_nl(stringformat("%s |",module_name)) end - io.flush() + ioflush() end + -- cgit v1.2.3 From 25444ac8cd48cd5ad7ed32bfcc9a0a1314e2223a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 15 Apr 2013 00:14:23 +0200 Subject: rewrite filename logger --- otfl-luat-ovr.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'otfl-luat-ovr.lua') diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua index 984dbf5..63ad6a7 100644 --- a/otfl-luat-ovr.lua +++ b/otfl-luat-ovr.lua @@ -11,9 +11,32 @@ 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 +--[[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 set_loglevel = function (n) + if type(n) == "number" then + loglevel = n + end +end +logs.set_loglevel = set_loglevel + function logs.report(category,fmt,...) if fmt then texiowrite_nl('log', stringformat("%s | %s: %s",module_name,category,stringformat(fmt,...))) @@ -35,3 +58,14 @@ function logs.info(category,fmt,...) ioflush() end +logs.names_loading = function (category, fmt, ...) + if loglevel > 1 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() + end +end + +-- vim:tw=71:sw=4:ts=4:expandtab -- cgit v1.2.3 From 5a8c4657de6b599e1897d8ac4e685264e0ac0587 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 15 Apr 2013 00:57:10 +0200 Subject: unify logging --- otfl-luat-ovr.lua | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'otfl-luat-ovr.lua') 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 -- cgit v1.2.3 From 283761cb68bff34c7d69a96b563382aa5e5a5142 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 15 Apr 2013 01:01:25 +0200 Subject: finish move to new loggers --- otfl-luat-ovr.lua | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'otfl-luat-ovr.lua') diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua index 0657bbe..c57c68e 100644 --- a/otfl-luat-ovr.lua +++ b/otfl-luat-ovr.lua @@ -37,26 +37,6 @@ local set_loglevel = function (n) end logs.set_loglevel = set_loglevel -function logs.report(category,fmt,...) - if fmt then - texiowrite_nl('log', stringformat("%s | %s: %s",module_name,category,stringformat(fmt,...))) - elseif category then - texiowrite_nl('log', stringformat("%s | %s",module_name,category)) - else - texiowrite_nl('log', stringformat("%s |",module_name)) - end -end - -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("log", tableconcat(res)) - end -end - - local log = function (category, fmt, ...) local res = { module_name, " |" } if category then res[#res+1] = " " .. category end -- cgit v1.2.3 From 6db1231adfffc18f1d015a4b916a7ad51d9a5aa4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 15 Apr 2013 01:10:34 +0200 Subject: cosmetic changes to luat-ovr --- otfl-luat-ovr.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'otfl-luat-ovr.lua') diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua index c57c68e..2a8af9e 100644 --- a/otfl-luat-ovr.lua +++ b/otfl-luat-ovr.lua @@ -12,7 +12,6 @@ local module_name = "luaotfload" local texiowrite_nl = texio.write_nl local stringformat = string.format local tableconcat = table.concat -local dummyfunction = function() end local type = type --[[doc-- @@ -31,9 +30,9 @@ We recreate the verbosity levels previously implemented in font-nms: local loglevel = 1 --- default local set_loglevel = function (n) - if type(n) == "number" then - loglevel = n - end + if type(n) == "number" then + loglevel = n + end end logs.set_loglevel = set_loglevel -- cgit v1.2.3 From 17893ca1a58ea8bcea492df192209bc96432fcd0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 15 Apr 2013 01:49:06 +0200 Subject: =?UTF-8?q?make=20the=20=E2=80=9Cverbose=E2=80=9D=20switch=20effec?= =?UTF-8?q?tive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otfl-luat-ovr.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'otfl-luat-ovr.lua') diff --git a/otfl-luat-ovr.lua b/otfl-luat-ovr.lua index 2a8af9e..bd04eeb 100644 --- a/otfl-luat-ovr.lua +++ b/otfl-luat-ovr.lua @@ -28,6 +28,7 @@ We recreate the verbosity levels previously implemented in font-nms: --doc]]-- local loglevel = 1 --- default +local logout = "log" local set_loglevel = function (n) if type(n) == "number" then @@ -36,11 +37,20 @@ local set_loglevel = function (n) 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("log", tableconcat(res)) + texiowrite_nl(logout, tableconcat(res)) end local stdout = function (category, fmt, ...) -- cgit v1.2.3