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 --- mkluatexfontdb.lua | 25 +++++++++++++++++++------ otfl-luat-ovr.lua | 12 +++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/mkluatexfontdb.lua b/mkluatexfontdb.lua index 0f0df9f..3e1caf3 100755 --- a/mkluatexfontdb.lua +++ b/mkluatexfontdb.lua @@ -53,6 +53,7 @@ Valid options: -vvv print all steps of directory searching -V --version print version and exit -h --help print this message + --log=stdout redirect log output to stdout The font database will be saved to %s @@ -73,22 +74,24 @@ Here we fill cmdargs with the good values, and then analyze it. local long_options = { force = "f", - quiet = "q", help = "h", + log = 1, + quiet = "q", verbose = 1 , version = "V", } -local short_options = "fqpvVh" +local short_options = "fqvVh" local force_reload = nil local function process_cmdline() - local options, _, _ = alt_getopt.get_ordered_opts (arg, - short_options, - long_options) + local options, _, optarg = + alt_getopt.get_ordered_opts (arg, short_options, long_options) local log_level = 1 - for _,v in next, options do + local nopts = #options + for n=1, nopts do + local v = options[n] if v == "q" then log_level = 0 elseif v == "v" then @@ -105,6 +108,16 @@ local function process_cmdline() os.exit(0) elseif v == "f" then force_reload = 1 + elseif v == "verbose" then + local lvl = optarg[n] + if lvl then + log_level = tonumber(lvl) + end + elseif v == "log" then + local str = optarg[n] + if str then + logs.set_logout(str) + end end end logs.set_loglevel(log_level) 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