From bb4ed0bee36aebbb12362a2237c154d2006a7ee3 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 7 Feb 2014 22:36:32 +0100 Subject: [db] copy names fields from tfmdata and insert fallbacks for broken names --- luaotfload-database.lua | 114 ++++++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 77a7162..d9bba80 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1373,23 +1373,7 @@ local get_size_info = function (metadata) return false end -local get_english_names = function (metadata, basename) - local validation_state = metadata.validation_state - if validation_state - and tablecontains (validation_state, "bad_ps_fontname") - then - report("both", 3, "db", - "%s has invalid postscript font names, using dummies.", - basename) - --- Broken names table, e.g. avkv.ttf with UTF-16 strings; - --- we put some dummies in place like the fontloader - --- (font-otf.lua) does. - return { - fontname = "bad-fontname-" .. basename, - fullname = "bad-fullname-" .. basename, - } - end - +local get_english_names = function (metadata) local names = metadata.names local english_names @@ -1397,34 +1381,78 @@ local get_english_names = function (metadata, basename) --inspect(names) for _, raw_namedata in next, names do if raw_namedata.lang == "English (US)" then - english_names = raw_namedata.names + return raw_namedata.names end end end - if not english_names then - -- no (English) names table, probably a broken font + -- no (English) names table, probably a broken font + report("both", 3, "db", + "%s: missing or broken English names table.", basename) + return { fontname = metadata.fontname, + fullname = metadata.fullname, } +end + +--[[-- + In case of broken PS names we set some dummies. However, we cannot + directly modify the font data as returned by fontloader.open() because + it is a userdata object. + + For this reason we copy what is necessary whilst keeping the table + structure the same as in the tfmdata. +--]]-- +local get_raw_info = function (metadata, basename) + local fullname + local fontname + local psname + + local validation_state = metadata.validation_state + if validation_state + and tablecontains (validation_state, "bad_ps_fontname") + then + --- Broken names table, e.g. avkv.ttf with UTF-16 strings; + --- we put some dummies in place like the fontloader + --- (font-otf.lua) does. report("both", 3, "db", - "%s: missing or broken names table.", basename) + "%s has invalid postscript font names, using dummies.", + basename) + fontname = "bad-fontname-" .. basename + fullname = "bad-fullname-" .. basename + else + fontname = metadata.fontname + fullname = metadata.fullname end - return english_names or { } + return { + familyname = metadata.familyname, + fontname = fontname, + fontstyle_name = metadata.fontstyle_name, + fullname = fullname, + italicangle = metadata.italicangle, + names = metadata.names, + pfminfo = metadata.pfminfo, + units_per_em = metadata.units_per_em, + version = metadata.version, + design_size = metadata.design_size, + design_range_top = metadata.design_range_top, + design_range_bottom = metadata.design_range_bottom, + } end -local organize_namedata = function (metadata, +local organize_namedata = function (rawinfo, english_names, basename, info) local default_name = english_names.compatfull or english_names.fullname or english_names.postscriptname - or metadata.fullname - or metadata.fontname + or rawinfo.fullname + or rawinfo.fontname or info.fullname or info.fontname local default_family = english_names.preffamily or english_names.family - or metadata.familyname + or rawinfo.familyname or info.familyname -- local default_modifier = english_names.prefmodifiers -- or english_names.subfamily @@ -1458,9 +1486,9 @@ local organize_namedata = function (metadata, }, metadata = { - fullname = metadata.fullname, - fontname = metadata.fontname, - familyname = metadata.familyname, + fullname = rawinfo.fullname, + fontname = rawinfo.fontname, + familyname = rawinfo.familyname, }, info = { @@ -1471,14 +1499,14 @@ local organize_namedata = function (metadata, } -- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size - if metadata.fontstyle_name then + if rawinfo.fontstyle_name then --- not present in all fonts, often differs from the preferred --- subfamily as well as subfamily fields, e.g. with --- LMSans10-BoldOblique: --- subfamily: “Bold Italic” --- prefmodifiers: “10 Bold Oblique” --- fontstyle_name: “Bold Oblique” - for _, name in next, metadata.fontstyle_name do + for _, name in next, rawinfo.fontstyle_name do if name.lang == 1033 then --- I hate magic numbers fontnames.fontstyle_name = name.name end @@ -1487,9 +1515,9 @@ local organize_namedata = function (metadata, return { sanitized = sanitize_fontnames (fontnames), - fontname = metadata.fontname, - fullname = metadata.fullname, - familyname = metadata.familyname, + fontname = rawinfo.fontname, + fullname = rawinfo.fullname, + familyname = rawinfo.familyname, } end @@ -1546,13 +1574,18 @@ ot_fullinfo = function (filename, return nil end - local english_names = get_english_names (metadata, basename) - local namedata = organize_namedata (metadata, + local rawinfo = get_raw_info (metadata, basename) + --- Closing the file manually is a tad faster and more memory + --- efficient than having it closed by the gc + fontloaderclose (metadata) + + local english_names = get_english_names (rawinfo) + local namedata = organize_namedata (rawinfo, english_names, basename, info) local style = organize_styledata (namedata.fontname, - metadata, + rawinfo, english_names, info) @@ -1564,11 +1597,8 @@ ot_fullinfo = function (filename, format = format, names = namedata, style = style, - version = metadata.version, + version = rawinfo.version, } - --- Closing the file manually is a tad faster and more memory - --- efficient than having it closed by the gc - fontloaderclose (metadata) return res end @@ -2577,7 +2607,7 @@ local pull_values = function (entry) --- pull name info ... entry.psname = english.psname - entry.fontname = info.fontname + entry.fontname = info.fontname or metadata.fontname entry.fullname = english.fullname or info.fullname entry.splainname = metadata.fullname entry.prefmodifiers = english.prefmodifiers -- cgit v1.2.3 From 4ec63fd11536844ed53c16006ac37a33623e61e8 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 8 Feb 2014 20:36:32 +0100 Subject: [log,override,main,tool] move logging functionality into separate file --- luaotfload-log.lua | 406 ++++++++++++++++++++++++++++++++++++++++++++++++ luaotfload-main.lua | 3 +- luaotfload-override.lua | 399 +++-------------------------------------------- luaotfload-tool.lua | 2 +- 4 files changed, 430 insertions(+), 380 deletions(-) create mode 100644 luaotfload-log.lua diff --git a/luaotfload-log.lua b/luaotfload-log.lua new file mode 100644 index 0000000..938050a --- /dev/null +++ b/luaotfload-log.lua @@ -0,0 +1,406 @@ +if not modules then modules = { } end modules ["luaotfload-log"] = { + version = "2.5", + comment = "companion to Luaotfload", + author = "Khaled Hosny, Elie Roux, Philipp Gesang", + copyright = "Luaotfload Development Team", + license = "GNU GPL v2.0" +} + +--[[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" --- prefix for messages + +local ioopen = io.open +local iowrite = io.write +local lfsisdir = lfs.isdir +local lfsisfile = lfs.isfile +local md5sumhexa = md5.sumhexa +local osdate = os.date +local ostime = os.time +local select = select +local stringformat = string.format +local stringsub = string.sub +local tableconcat = table.concat +local texiowrite_nl = texio.write_nl +local texiowrite = texio.write +local type = type + +local dummyfunction = function () end + +local texjob = false +if tex and (tex.jobname or tex.formatname) then + --- TeX + texjob = true +end + +local loglevel = 0 --- default +local logout = "log" + +--- int -> bool +local set_loglevel = function (n) + if type(n) == "number" then + loglevel = n + end + return true +end +logs.setloglevel = set_loglevel +logs.set_loglevel = set_loglevel +logs.set_log_level = set_loglevel --- accomodating lazy typists + +--- unit -> int +local get_loglevel = function ( ) + return loglevel +end +logs.getloglevel = get_loglevel +logs.get_loglevel = get_loglevel +logs.get_log_level = get_loglevel + +local writeln --- pointer to terminal/log writer +local statusln --- terminal writer that reuses the current line +local first_status = true --- indicate the begin of a status region + +local log_msg = [[ +logging output redirected to %s +to monitor the progress run "tail -f %s" in another terminal +]] + +local tmppath = os.getenv "TMPDIR" or "/tmp" + +local choose_logfile = function ( ) + if lfsisdir (tmppath) then + local fname + repeat --- ensure that file of that name doesn’t exist + --- TODO this could use os.uuid() instead of md5 + fname = tmppath .. "/luaotfload-log-" + .. stringsub (md5sumhexa (ostime ()), 1, 8) + until not lfsisfile (fname) + iowrite (stringformat (log_msg, fname, fname)) + return ioopen (fname, "w") + end + --- missing /tmp + return false +end + +local set_logout = function (s, finalizers) + if s == "stdout" then + logout = "redirect" + elseif s == "file" then --- inject custom logger + logout = "redirect" + local chan = choose_logfile () + chan:write (stringformat ("logging initiated at %s", + osdate ("%F %T", ostime ()))) + local writefile = function (...) + if select ("#", ...) == 2 then + chan:write (select (2, ...)) + else + chan:write (select (1, ...)) + end + end + local writefile_nl= function (...) + chan:write "\n" + if select ("#", ...) == 2 then + chan:write (select (2, ...)) + else + chan:write (select (1, ...)) + end + end + + local writeln_orig = writeln + + texiowrite = writefile + texiowrite_nl = writefile_nl + writeln = writefile_nl + statusln = dummyfunction + + finalizers[#finalizers+1] = function () + chan:write (stringformat ("\nlogging finished at %s\n", + osdate ("%F %T", ostime ()))) + chan:close () + texiowrite = texio.write + texiowrite_nl = texio.write_nl + writeln = writeln_orig + end + --else --- remains “log” + end + return finalizers +end + +logs.set_logout = set_logout + +local log = function (category, fmt, ...) + local res = { module_name, "|", category, ":" } + if fmt then + res [#res + 1] = stringformat (fmt, ...) + end + texiowrite_nl (logout, tableconcat(res, " ")) +end + +--- 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 kill_line = "\r\x1b[K" + +if texjob == true then + --- We imitate the texio.* functions so the output is consistent. + writeln = function (str) + iowrite "\n" + iowrite(str) + end + statusln = function (str) + if first_status == false then + iowrite (kill_line) + else + iowrite "\n" + end + iowrite (str) + end +else + writeln = function (str) + iowrite(str) + iowrite "\n" + end + statusln = function (str) + if first_status == false then + iowrite (kill_line) + end + iowrite (str) + end +end + +stdout = function (writer, category, ...) + local res = { module_name, "|", category, ":" } + local nargs = select("#", ...) + if nargs == 0 then + --writeln tableconcat(res, " ") + --return + elseif nargs == 1 then + res[#res+1] = select(1, ...) -- around 30% faster than unpack() + else + res[#res+1] = stringformat(...) + end + writer (tableconcat(res, " ")) +end + +--- at default (zero), we aim to be quiet +local level_ids = { common = 1, loading = 2, search = 3 } + +--[[doc-- + + The names_report logger is used more or less all over luaotfload. + Its requirements are twofold: + + 1) Provide two logging channels, the terminal and the log file; + 2) Allow for control over verbosity levels. + + The first part is addressed by specifying the log *mode* as the + first argument that can be either “log”, meaning the log file, or + “both”: log file and stdout. Anything else is taken as referring to + stdout only. + + Verbosity levels, though not as fine-grained as e.g. Context’s + system of tracers, allow keeping the logging spam caused by + different subsystems manageable. By default, luaotfload will not + emit anything if things are running smoothly on level zero. Only + warning messages are relayed, while the other messages are skipped + over. (This is a little sub-optimal performance-wise since the + function calls to the logger are executed regardless.) The log + level during a Luatex run can be adjusted by setting the “loglevel” + field in config.luaotfload, or by calling logs.set_loglevel() as + defined above. + +--doc]]-- + +local 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 (...) + elseif mode == "both" and logout ~= "redirect" then + log (...) + stdout (writeln, ...) + else + stdout (writeln, ...) + end + end +end + +logs.names_report = names_report + +--[[doc-- + + status_logger -- Overwrites the most recently printed line of the + terminal. Its purpose is to provide feedback without spamming + stdout with irrelevant messages, i.e. when building the database. + + Status logging must be initialized by calling status_start() and + properly reset via status_stop(). + + The arguments low and high indicate the loglevel threshold at which + linewise and full logging is triggered, respectively. E.g. + + names_status (1, 4, "term", "Hello, world!") + + will print nothing if the loglevel is less than one, reuse the + current line if the loglevel ranges from one to three inclusively, + and output the message on a separate line otherwise. + +--doc]]-- + +local status_logger = function (mode, ...) + if mode == "log" then + log (...) + else + if mode == "both" and logout ~= "redirect" then + log (...) + stdout (statusln, ...) + else + stdout (statusln, ...) + end + first_status = false + end +end + +--[[doc-- + + status_start -- Initialize status logging. This installs the status + logger if the loglevel is in the specified range, and the normal + logger otherwise. It also resets the first line state which + causing the next line printed using the status logger to not kill + the current line. + +--doc]]-- + +local status_writer +local status_low = 99 +local status_high = 99 + +local status_start = function (low, high) + first_status = true + status_low = low + status_high = high + + if os.type == "windows" --- Assume broken terminal. + or os.getenv "TERM" == "dumb" + then + status_writer = function (mode, ...) + names_report (mode, high, ...) + end + return + end + + if low <= loglevel and loglevel < high then + status_writer = status_logger + else + status_writer = function (mode, ...) + names_report (mode, high, ...) + end + end +end + +--[[doc-- + + status_stop -- Finalize a status region by outputting a newline and + printing a message. + +--doc]]-- + +local status_stop = function (...) + if first_status == false then + status_writer(...) + if texjob == false then + writeln "" + end + end +end + +logs.names_status = function (...) status_writer (...) end +logs.names_status_start = status_start +logs.names_status_stop = status_stop + +--[[doc-- + + The fontloader comes with the Context logging mechanisms + inaccessible. Instead, it provides dumb fallbacks based + on the functions in texio.write*() that can be overridden + by providing a function texio.reporter(). + + The fontloader output can be quite verbose, so we disable + it entirely by default. + +--doc]]-- + +local texioreporter = function (message) + names_report("log", 2, message) +end + +texio.reporter = texioreporter + +--[[doc-- + + Adobe Glyph List. + ------------------------------------------------------------------- + + Context provides a somewhat different font-age.lua from an unclear + origin. Unfortunately, the file name it reads from is hard-coded + in font-enc.lua, so we have to replace the entire table. + + This shouldn’t cause any complications. Due to its implementation + the glyph list will be loaded upon loading a OTF or TTF for the + first time during a TeX run. (If one sticks to TFM/OFM then it is + never read at all.) For this reason we can install a metatable that + looks up the file of our choosing and only falls back to the + Context one in case it cannot be found. + +--doc]]-- + +if fonts then --- need to be running TeX + if next(fonts.encodings.agl) then + --- unnecessary because the file shouldn’t be loaded at this time + --- but we’re just making sure + fonts.encodings.agl = nil + collectgarbage"collect" + end + + + fonts.encodings.agl = { } + + setmetatable(fonts.encodings.agl, { __index = function (t, k) + if k == "unicodes" then + local glyphlist = resolvers.findfile"luaotfload-glyphlist.lua" + if glyphlist then + names_report("log", 1, "load", "loading the Adobe glyph list") + else + glyphlist = resolvers.findfile"font-age.lua" + names_report("both", 0, "load", + "loading the extended glyph list from ConTeXt") + end + local unicodes = dofile(glyphlist) + fonts.encodings.agl = { unicodes = unicodes } + return unicodes + else + return nil + end + end }) +end + +-- vim:tw=71:sw=4:ts=4:expandtab diff --git a/luaotfload-main.lua b/luaotfload-main.lua index 27f0a99..3f356ed 100644 --- a/luaotfload-main.lua +++ b/luaotfload-main.lua @@ -409,7 +409,8 @@ add_to_callback("hpack_filter", add_to_callback("find_vf_file", find_vf_file, "luaotfload.find_vf_file") -loadmodule "override.lua" --- “luat-ovr” +loadmodule "log.lua" --- messages; used to be part of -override +loadmodule "override.lua" --- load glyphlist on demand logs.set_loglevel(config.luaotfload.loglevel) diff --git a/luaotfload-override.lua b/luaotfload-override.lua index 7cb9c5d..4363b74 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['luat-ovr'] = { +if not modules then modules = { } end modules ["luaotfload-override"] = { version = "2.5", comment = "companion to Luaotfload", author = "Khaled Hosny, Elie Roux, Philipp Gesang", @@ -6,355 +6,9 @@ if not modules then modules = { } end modules ['luat-ovr'] = { license = "GNU GPL v2.0" } ---[[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 ioopen = io.open -local iowrite = io.write -local lfsisdir = lfs.isdir -local lfsisfile = lfs.isfile -local md5sumhexa = md5.sumhexa -local osdate = os.date -local ostime = os.time -local select = select -local stringformat = string.format -local stringsub = string.sub -local tableconcat = table.concat -local texio_write_nl = texio.write_nl -local texiowrite_nl = texio.write_nl -local texio_write = texio.write -local texiowrite = texio.write -local type = type - -local dummyfunction = function () end - -local texjob = false -if tex and (tex.jobname or tex.formatname) then - --- TeX - texjob = true -end - -local loglevel = 0 --- default -local logout = "log" - ---- int -> bool -local set_loglevel = function (n) - if type(n) == "number" then - loglevel = n - end - return true -end -logs.setloglevel = set_loglevel -logs.set_loglevel = set_loglevel -logs.set_log_level = set_loglevel --- accomodating lazy typists - ---- unit -> int -local get_loglevel = function ( ) - return loglevel -end -logs.getloglevel = get_loglevel -logs.get_loglevel = get_loglevel -logs.get_log_level = get_loglevel - -local writeln --- pointer to terminal/log writer -local statusln --- terminal writer that reuses the current line -local first_status = true --- indicate the begin of a status region - -local log_msg = [[ -logging output redirected to %s -to monitor the progress run "tail -f %s" in another terminal -]] - -local tmppath = os.getenv "TMPDIR" or "/tmp" - -local choose_logfile = function ( ) - if lfsisdir (tmppath) then - local fname - repeat --- ensure that file of that name doesn’t exist - fname = tmppath .. "/luaotfload-log-" - .. stringsub (md5sumhexa (ostime ()), 1, 8) - until not lfsisfile (fname) - iowrite (stringformat (log_msg, fname, fname)) - return ioopen (fname, "w") - end - --- missing /tmp - return false -end - -local set_logout = function (s, finalizers) - if s == "stdout" then - logout = "redirect" - elseif s == "file" then --- inject custom logger - logout = "redirect" - local chan = choose_logfile () - chan:write (stringformat ("logging initiated at %s", - osdate ("%F %T", ostime ()))) - local writefile = function (...) - if select ("#", ...) == 2 then - chan:write (select (2, ...)) - else - chan:write (select (1, ...)) - end - end - local writefile_nl= function (...) - chan:write "\n" - if select ("#", ...) == 2 then - chan:write (select (2, ...)) - else - chan:write (select (1, ...)) - end - end - - local writeln_orig = writeln - - texiowrite = writefile - texiowrite_nl = writefile_nl - writeln = writefile_nl - statusln = dummyfunction - - finalizers[#finalizers+1] = function () - chan:write (stringformat ("\nlogging finished at %s\n", - osdate ("%F %T", ostime ()))) - chan:close () - texiowrite = texio.write - texiowrite_nl = texio.write_nl - writeln = writeln_orig - end - --else --- remains “log” - end - return finalizers -end - -logs.set_logout = set_logout - -local log = function (category, fmt, ...) - local res = { module_name, "|", category, ":" } - if fmt then - res [#res + 1] = stringformat (fmt, ...) - end - texiowrite_nl (logout, tableconcat(res, " ")) -end - ---- 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 kill_line = "\r\x1b[K" - -if texjob == true then - --- We imitate the texio.* functions so the output is consistent. - writeln = function (str) - iowrite "\n" - iowrite(str) - end - statusln = function (str) - if first_status == false then - iowrite (kill_line) - else - iowrite "\n" - end - iowrite (str) - end -else - writeln = function (str) - iowrite(str) - iowrite "\n" - end - statusln = function (str) - if first_status == false then - iowrite (kill_line) - end - iowrite (str) - end -end - -stdout = function (writer, category, ...) - local res = { module_name, "|", category, ":" } - local nargs = select("#", ...) - if nargs == 0 then - --writeln tableconcat(res, " ") - --return - elseif nargs == 1 then - res[#res+1] = select(1, ...) -- around 30% faster than unpack() - else - res[#res+1] = stringformat(...) - end - writer (tableconcat(res, " ")) -end - ---- at default (zero), we aim to be quiet -local level_ids = { common = 1, loading = 2, search = 3 } - ---[[doc-- - - The names_report logger is used more or less all over luaotfload. - Its requirements are twofold: - - 1) Provide two logging channels, the terminal and the log file; - 2) Allow for control over verbosity levels. - - The first part is addressed by specifying the log *mode* as the - first argument that can be either “log”, meaning the log file, or - “both”: log file and stdout. Anything else is taken as referring to - stdout only. - - Verbosity levels, though not as fine-grained as e.g. Context’s - system of tracers, allow keeping the logging spam caused by - different subsystems manageable. By default, luaotfload will not - emit anything if things are running smoothly on level zero. Only - warning messages are relayed, while the other messages are skipped - over. (This is a little sub-optimal performance-wise since the - function calls to the logger are executed regardless.) The log - level during a Luatex run can be adjusted by setting the “loglevel” - field in config.luaotfload, or by calling logs.set_loglevel() as - defined above. - ---doc]]-- - -local 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 (...) - elseif mode == "both" and logout ~= "redirect" then - log (...) - stdout (writeln, ...) - else - stdout (writeln, ...) - end - end -end - -logs.names_report = names_report - ---[[doc-- - - status_logger -- Overwrites the most recently printed line of the - terminal. Its purpose is to provide feedback without spamming - stdout with irrelevant messages, i.e. when building the database. - - Status logging must be initialized by calling status_start() and - properly reset via status_stop(). - - The arguments low and high indicate the loglevel threshold at which - linewise and full logging is triggered, respectively. E.g. - - names_status (1, 4, "term", "Hello, world!") - - will print nothing if the loglevel is less than one, reuse the - current line if the loglevel ranges from one to three inclusively, - and output the message on a separate line otherwise. - ---doc]]-- - -local status_logger = function (mode, ...) - if mode == "log" then - log (...) - else - if mode == "both" and logout ~= "redirect" then - log (...) - stdout (statusln, ...) - else - stdout (statusln, ...) - end - first_status = false - end -end - ---[[doc-- - - status_start -- Initialize status logging. This installs the status - logger if the loglevel is in the specified range, and the normal - logger otherwise. It also resets the first line state which - causing the next line printed using the status logger to not kill - the current line. - ---doc]]-- - -local status_writer -local status_low = 99 -local status_high = 99 - -local status_start = function (low, high) - first_status = true - status_low = low - status_high = high - - if os.type == "windows" --- Assume broken terminal. - or os.getenv "TERM" == "dumb" - then - status_writer = function (mode, ...) - names_report (mode, high, ...) - end - return - end - - if low <= loglevel and loglevel < high then - status_writer = status_logger - else - status_writer = function (mode, ...) - names_report (mode, high, ...) - end - end -end - ---[[doc-- - - status_stop -- Finalize a status region by outputting a newline and - printing a message. - ---doc]]-- - -local status_stop = function (...) - if first_status == false then - status_writer(...) - if texjob == false then - writeln "" - end - end -end - -logs.names_status = function (...) status_writer (...) end -logs.names_status_start = status_start -logs.names_status_stop = status_stop - ---[[doc-- - - The fontloader comes with the Context logging mechanisms - inaccessible. Instead, it provides dumb fallbacks based - on the functions in texio.write*() that can be overridden - by providing a function texio.reporter(). - - The fontloader output can be quite verbose, so we disable - it entirely by default. - ---doc]]-- - -local texioreporter = function (message) - names_report("log", 2, message) -end - -texio.reporter = texioreporter +local findfile = resolvers.findfile +local names_report = logs.names_report +local encodings = fonts.encodings --[[doc-- @@ -374,34 +28,23 @@ texio.reporter = texioreporter --doc]]-- -if fonts then --- need to be running TeX - if next(fonts.encodings.agl) then - --- unnecessary because the file shouldn’t be loaded at this time - --- but we’re just making sure - fonts.encodings.agl = nil - collectgarbage"collect" - end - - - fonts.encodings.agl = { } +encodings.agl = { } - setmetatable(fonts.encodings.agl, { __index = function (t, k) - if k == "unicodes" then - local glyphlist = resolvers.findfile"luaotfload-glyphlist.lua" - if glyphlist then - names_report("log", 1, "load", "loading the Adobe glyph list") - else - glyphlist = resolvers.findfile"font-age.lua" - names_report("both", 0, "load", - "loading the extended glyph list from ConTeXt") - end - local unicodes = dofile(glyphlist) - fonts.encodings.agl = { unicodes = unicodes } - return unicodes - else - return nil - end - end }) -end +setmetatable(fonts.encodings.agl, { __index = function (t, k) + if k ~= "unicodes" then + return nil + end + local glyphlist = findfile "luaotfload-glyphlist.lua" + if glyphlist then + names_report("log", 1, "load", "loading the Adobe glyph list") + else + glyphlist = findfile "font-age.lua" + names_report("both", 0, "load", + "loading the extended glyph list from ConTeXt") + end + local unicodes = dofile(glyphlist) + encodings.agl = { unicodes = unicodes } + return unicodes +end }) -- vim:tw=71:sw=4:ts=4:expandtab diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 8bc590a..6ca7d69 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -141,7 +141,7 @@ require"luaotfload-basics-gen.lua" texio.write, texio.write_nl = backup.write, backup.write_nl utilities = backup.utilities -require"luaotfload-override.lua" --- this populates the logs.* namespace +require"luaotfload-log.lua" --- this populates the logs.* namespace require"luaotfload-parsers" --- fonts.conf and request syntax require"luaotfload-database" require"alt_getopt" -- cgit v1.2.3 From 2c73e4165909bc0d82cc62a9031bd687a5e000b6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 9 Feb 2014 13:57:49 +0100 Subject: [log] use UUID instead of MD5(time) when creating log files --- luaotfload-log.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/luaotfload-log.lua b/luaotfload-log.lua index 938050a..d057eb3 100644 --- a/luaotfload-log.lua +++ b/luaotfload-log.lua @@ -19,9 +19,9 @@ local ioopen = io.open local iowrite = io.write local lfsisdir = lfs.isdir local lfsisfile = lfs.isfile -local md5sumhexa = md5.sumhexa local osdate = os.date local ostime = os.time +local osuuid = os.uuid local select = select local stringformat = string.format local stringsub = string.sub @@ -75,9 +75,7 @@ local choose_logfile = function ( ) if lfsisdir (tmppath) then local fname repeat --- ensure that file of that name doesn’t exist - --- TODO this could use os.uuid() instead of md5 - fname = tmppath .. "/luaotfload-log-" - .. stringsub (md5sumhexa (ostime ()), 1, 8) + fname = tmppath .. "/luaotfload-log-" .. osuuid() until not lfsisfile (fname) iowrite (stringformat (log_msg, fname, fname)) return ioopen (fname, "w") -- cgit v1.2.3 From 73ab3c0ae57a4918b6149ae862fc3a24c7651190 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 9 Feb 2014 13:59:25 +0100 Subject: [doc] update manpage paragraph about --log --- luaotfload-tool.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 2ac206f..6863918 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -188,10 +188,10 @@ miscellaneous troubleshooting), where *CHANNEL* can be 1) ``stdout`` -> all output will be - dumped to the terminal; or + dumped to the terminal (default); or 2) ``file`` -> write to a file to the temporary directory (the name will be chosen - automatically (**experimental!**). + automatically. --version, -V Show version numbers of components as well as some basic information and exit. -- cgit v1.2.3 From 405ff5a3f24566f76a3d08d7ba217a137fcb5bdd Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 9 Feb 2014 14:04:26 +0100 Subject: [*] update references to luaotfload-override/luaotfload-log --- NEWS | 1 + filegraph.dot | 3 ++- mkstatus | 1 + mktests | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2e2bf8f..6be91b4 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Change History * Move the heavier LPEG parsers from luaotfload-features (syntax) and luaotfload-database (fontconfig) into the new file luaotfload-parsers.lua. + * Move logging routines from luaotfload-override in to luaotfload-log. 2013/12/31, luaotfload v2.4 * Additional self-tests, now in separate file (luaotfload-diagnostics.lua) diff --git a/filegraph.dot b/filegraph.dot index 90e6e5c..47db9ea 100644 --- a/filegraph.dot +++ b/filegraph.dot @@ -200,8 +200,9 @@ strict digraph luaotfload_files { //looks weird with circo ... Luaotfload Libraries luaotfload-auxiliary.lua luaotfload-features.lua luaotfload-override.lua luaotfload-loaders.lua + luaotfload-log.lua luaotfload-letterspace.lua luaotfload-parsers.lua luaotfload-database.lua - luaotfload-color.lua luaotfload-letterspace.lua + luaotfload-color.lua >, ] diff --git a/mkstatus b/mkstatus index 28b80ff..6e6e375 100755 --- a/mkstatus +++ b/mkstatus @@ -50,6 +50,7 @@ local names = { "luaotfload-glyphlist.lua", "luaotfload-letterspace.lua", "luaotfload-loaders.lua", + "luaotfload-log.lua", "luaotfload-main.lua", "luaotfload-fontloader.lua", "luaotfload-override.lua", diff --git a/mktests b/mktests index 3a55b8d..0bf3f64 100755 --- a/mktests +++ b/mktests @@ -30,7 +30,7 @@ kpse.set_program_name "luatex" require "lualibs" require "luaotfload-basics-gen.lua" -require "luaotfload-override.lua" +require "luaotfload-log.lua" require "luaotfload-parsers" require "luaotfload-database" -- cgit v1.2.3 From e069690a7f747f7b17baed6974168192857eb485 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 9 Feb 2014 15:15:46 +0100 Subject: [log,*] move logs -> luaotfload.log Next step toward https://github.com/lualatex/luaotfload/issues/169 Signed-off-by: Philipp Gesang --- luaotfload-auxiliary.lua | 61 ++++++++++++++++++----------------- luaotfload-database.lua | 28 +++++++++------- luaotfload-diagnostics.lua | 3 +- luaotfload-features.lua | 3 +- luaotfload-letterspace.lua | 11 ++++--- luaotfload-log.lua | 34 ++++++++++---------- luaotfload-main.lua | 60 +++++++++++++++++++--------------- luaotfload-override.lua | 4 ++- luaotfload-parsers.lua | 4 +-- luaotfload-tool.lua | 80 ++++++++++++++++++++++++---------------------- 10 files changed, 157 insertions(+), 131 deletions(-) diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index 334ac47..9ab78e7 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -17,7 +17,7 @@ luaotfload.aux = luaotfload.aux or { } local aux = luaotfload.aux local log = luaotfload.log -local warning = luaotfload.log +local report = log.names_report local fonthashes = fonts.hashes local identifiers = fonthashes.identifiers @@ -54,8 +54,8 @@ local start_rewrite_fontname = function () rewrite_fontname, "luaotfload.rewrite_fontname") rewriting = true - logs.names_report ("log", 0, "aux", - "start rewriting tfmdata.name field") + report ("log", 0, "aux", + "start rewriting tfmdata.name field") end end @@ -66,8 +66,8 @@ local stop_rewrite_fontname = function () luatexbase.remove_fromt_callback ("luaotfload.patch_font", "luaotfload.rewrite_fontname") rewriting = false - logs.names_report ("log", 0, "aux", - "stop rewriting tfmdata.name field") + report ("log", 0, "aux", + "stop rewriting tfmdata.name field") end end @@ -366,7 +366,7 @@ do local load_chardef = function () - log ("Loading character metadata from %s.", chardef) + report ("both", 1, "aux", "Loading character metadata from %s.", chardef) chardata = dofile (kpse.find_file (chardef, "lua")) if chardata == nil then @@ -424,19 +424,19 @@ local provides_script = function (font_id, asked_script) --- where method: "gpos" | "gsub" for feature, data in next, featuredata do if data[asked_script] then - log(stringformat( - "font no %d (%s) defines feature %s for script %s", - font_id, fontname, feature, asked_script)) + report ("log", 1, "aux", + "font no %d (%s) defines feature %s for script %s", + font_id, fontname, feature, asked_script) return true end end end - log(stringformat( - "font no %d (%s) defines no feature for script %s", - font_id, fontname, asked_script)) + report ("log", 0, "aux", + "font no %d (%s) defines no feature for script %s", + font_id, fontname, asked_script) end end - log(stringformat("no font with id %d", font_id)) + report ("log", 0, "aux", "no font with id %d", font_id) return false end @@ -463,20 +463,22 @@ local provides_language = function (font_id, asked_script, asked_language) for feature, data in next, featuredata do local scriptdata = data[asked_script] if scriptdata and scriptdata[asked_language] then - log(stringformat("font no %d (%s) defines feature %s " - .. "for script %s with language %s", - font_id, fontname, feature, - asked_script, asked_language)) + report ("log", 1, "aux", + "font no %d (%s) defines feature %s " + .. "for script %s with language %s", + font_id, fontname, feature, + asked_script, asked_language) return true end end end - log(stringformat( - "font no %d (%s) defines no feature for script %s with language %s", - font_id, fontname, asked_script, asked_language)) + report ("log", 0, "aux", + "font no %d (%s) defines no feature " + .. "for script %s with language %s", + font_id, fontname, asked_script, asked_language) end end - log(stringformat("no font with id %d", font_id)) + report ("log", 0, "aux", "no font with id %d", font_id) return false end @@ -534,20 +536,21 @@ local provides_feature = function (font_id, asked_script, if feature then local scriptdata = feature[asked_script] if scriptdata and scriptdata[asked_language] then - log(stringformat("font no %d (%s) defines feature %s " - .. "for script %s with language %s", - font_id, fontname, asked_feature, - asked_script, asked_language)) + report ("log", 1, "aux", + "font no %d (%s) defines feature %s " + .. "for script %s with language %s", + font_id, fontname, asked_feature, + asked_script, asked_language) return true end end end - log(stringformat( - "font no %d (%s) does not define feature %s for script %s with language %s", - font_id, fontname, asked_feature, asked_script, asked_language)) + report ("log", 0, "aux", + "font no %d (%s) does not define feature %s for script %s with language %s", + font_id, fontname, asked_feature, asked_script, asked_language) end end - log(stringformat("no font with id %d", font_id)) + report ("log", 0, "aux", "no font with id %d", font_id) return false end diff --git a/luaotfload-database.lua b/luaotfload-database.lua index d9bba80..8f603db 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -44,6 +44,13 @@ local read_fonts_conf = parsers.read_fonts_conf local stripslashes = parsers.stripslashes local splitcomma = parsers.splitcomma +local log = luaotfload.log +local report = log.names_report +local report_status = log.names_status +local report_status_start = log.names_status_start +local report_status_stop = log.names_status_stop + + --- Luatex builtins local load = load local next = next @@ -151,11 +158,6 @@ local make_luanames = function (path) filereplacesuffix(path, "luc") end -local report = logs.names_report -local report_status = logs.names_status -local report_status_start = logs.names_status_start -local report_status_stop = logs.names_status_stop - --- The “termwidth” value is only considered when printing --- short status messages, e.g. when building the database --- online. @@ -231,7 +233,11 @@ if not runasscript then index.lua, index.luc = make_luanames (index_file) else --- running as script, inject some dummies caches = { } - logs = { report = function () end } + local dummy_function = function () end + log = { report = dummy_function, + report_status = dummy_function, + report_status_start = dummy_function, + report_status_stop = dummy_function, } end @@ -2284,7 +2290,7 @@ local scan_texmf_fonts = function (currentnames, targetnames, dry_run) report ("info", 1, "db", "Scanning TEXMF fonts...") else report ("info", 1, "db", "Scanning TEXMF and OS fonts...") - if logs.get_loglevel () > 3 then + if log.get_loglevel () > 3 then local osdirs = filesplitpath (osfontdir) report ("info", 0, "db", "$OSFONTDIR has %d entries:", #osdirs) @@ -2979,7 +2985,7 @@ local collect_statistics = function (mappings) local n_fullname = setsize (fullname) local n_family = setsize (family) - if logs.get_loglevel () > 1 then + if log.get_loglevel () > 1 then local pprint_top = function (hash, n, set) local freqs = { } @@ -3165,7 +3171,7 @@ update_names = function (currentnames, force, dry_run) if success then local success = save_lookups () if success then - logs.names_report ("info", 2, "cache", + report ("info", 2, "cache", "Lookup cache emptied.") return targetnames end @@ -3354,7 +3360,7 @@ end local purge_cache = function ( ) local writable_path = getwritablecachepath () local luanames, lucnames, rest = collect_cache(writable_path) - if logs.get_loglevel() > 1 then + if log.get_loglevel() > 1 then print_cache("writable path", writable_path, luanames, lucnames, rest) end local success = purge_from_cache("writable path", writable_path, luanames, false) @@ -3365,7 +3371,7 @@ end local erase_cache = function ( ) local writable_path = getwritablecachepath () local luanames, lucnames, rest, all = collect_cache(writable_path) - if logs.get_loglevel() > 1 then + if log.get_loglevel() > 1 then print_cache("writable path", writable_path, luanames, lucnames, rest) end local success = purge_from_cache("writable path", writable_path, all, true) diff --git a/luaotfload-diagnostics.lua b/luaotfload-diagnostics.lua index 1ae9a90..4ffaa06 100644 --- a/luaotfload-diagnostics.lua +++ b/luaotfload-diagnostics.lua @@ -49,8 +49,9 @@ local lpeg = require "lpeg" local C, Cg, Ct = lpeg.C, lpeg.Cg, lpeg.Ct local lpegmatch = lpeg.match +local names_report = luaotfload.log.names_report local out = function (...) - logs.names_report (false, 0, "diagnose", ...) + names_report (false, 0, "diagnose", ...) end local parsers = luaotfload.parsers diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 5172f4b..73edcd2 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -48,7 +48,8 @@ function fonts.definers.getspecification(str) return "", str, "", ":", str end -local report = logs.names_report +local log = luaotfload.log +local report = log.names_report local stringfind = string.find local stringlower = string.lower diff --git a/luaotfload-letterspace.lua b/luaotfload-letterspace.lua index 1957f9a..a855bf3 100644 --- a/luaotfload-letterspace.lua +++ b/luaotfload-letterspace.lua @@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['letterspace'] = { license = "see context related readme files" } +local log = luaotfload.log +local report = log.names_report + local getmetatable = getmetatable local require = require local setmetatable = setmetatable @@ -512,10 +515,10 @@ otffeatures.register { local initializecompatfontkerning = function (tfmdata, percentage) local factor = tonumber (percentage) if not factor then - logs.names_report ("both", 0, "letterspace", - "Invalid argument to letterspace: %s (type %q), " .. - "was expecting percentage as Lua number instead.", - percentage, type (percentage)) + names_report ("both", 0, "letterspace", + "Invalid argument to letterspace: %s (type %q), " .. + "was expecting percentage as Lua number instead.", + percentage, type (percentage)) return end return initializefontkerning (tfmdata, factor * 0.01) diff --git a/luaotfload-log.lua b/luaotfload-log.lua index d057eb3..080550a 100644 --- a/luaotfload-log.lua +++ b/luaotfload-log.lua @@ -15,6 +15,10 @@ because we lack a user interface to toggle per-subsystem tracing. local module_name = "luaotfload" --- prefix for messages +luaotfload = luaotfload or { } +luaotfload.log = luaotfload.log or { } +local log = luaotfload.log + local ioopen = io.open local iowrite = io.write local lfsisdir = lfs.isdir @@ -48,17 +52,13 @@ local set_loglevel = function (n) end return true end -logs.setloglevel = set_loglevel -logs.set_loglevel = set_loglevel -logs.set_log_level = set_loglevel --- accomodating lazy typists +log.set_loglevel = set_loglevel --- unit -> int local get_loglevel = function ( ) return loglevel end -logs.getloglevel = get_loglevel -logs.get_loglevel = get_loglevel -logs.get_log_level = get_loglevel +log.get_loglevel = get_loglevel local writeln --- pointer to terminal/log writer local statusln --- terminal writer that reuses the current line @@ -128,9 +128,9 @@ local set_logout = function (s, finalizers) return finalizers end -logs.set_logout = set_logout +log.set_logout = set_logout -local log = function (category, fmt, ...) +local basic_logger = function (category, fmt, ...) local res = { module_name, "|", category, ":" } if fmt then res [#res + 1] = stringformat (fmt, ...) @@ -219,7 +219,7 @@ local level_ids = { common = 1, loading = 2, search = 3 } over. (This is a little sub-optimal performance-wise since the function calls to the logger are executed regardless.) The log level during a Luatex run can be adjusted by setting the “loglevel” - field in config.luaotfload, or by calling logs.set_loglevel() as + field in config.luaotfload, or by calling log.set_loglevel() as defined above. --doc]]-- @@ -232,9 +232,9 @@ local names_report = function (mode, lvl, ...) if loglevel >= lvl then if mode == "log" then - log (...) + basic_logger (...) elseif mode == "both" and logout ~= "redirect" then - log (...) + basic_logger (...) stdout (writeln, ...) else stdout (writeln, ...) @@ -242,7 +242,7 @@ local names_report = function (mode, lvl, ...) end end -logs.names_report = names_report +log.names_report = names_report --[[doc-- @@ -266,10 +266,10 @@ logs.names_report = names_report local status_logger = function (mode, ...) if mode == "log" then - log (...) + basic_logger (...) else if mode == "both" and logout ~= "redirect" then - log (...) + basic_logger (...) stdout (statusln, ...) else stdout (statusln, ...) @@ -331,9 +331,9 @@ local status_stop = function (...) end end -logs.names_status = function (...) status_writer (...) end -logs.names_status_start = status_start -logs.names_status_stop = status_stop +log.names_status = function (...) status_writer (...) end +log.names_status_start = status_start +log.names_status_stop = status_stop --[[doc-- diff --git a/luaotfload-main.lua b/luaotfload-main.lua index 3f356ed..35c01f2 100644 --- a/luaotfload-main.lua +++ b/luaotfload-main.lua @@ -4,7 +4,7 @@ -- REQUIREMENTS: luatex v.0.78 or later, the lualibs package -- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang -- VERSION: same as Luaotfload --- MODIFIED: 2014-01-16 06:51:20+0100 +-- MODIFIED: 2014-02-09 14:42:22+0100 ----------------------------------------------------------------------- -- --- Note: @@ -45,6 +45,7 @@ if not modules then modules = { } end modules ["luaotfload-main"] = { luaotfload = luaotfload or { } local luaotfload = luaotfload +luaotfload.log = luaotfload.log or { } config = config or { } config.luaotfload = config.luaotfload or { } @@ -91,10 +92,12 @@ local dummy_function = function () end local error, warning, info, log = luatexbase.provides_module(luaotfload.module) -luaotfload.error = error -luaotfload.warning = warning -luaotfload.info = info -luaotfload.log = log +luaotfload.log.tex = { + error = error, + warning = warning, + info = info, + log = log, +} --[[doc-- @@ -143,6 +146,12 @@ local loadmodule = function (name) require(fl_prefix .."-"..name) end +loadmodule "log.lua" --- messages; used to be part of -override +local log = luaotfload.log +local report = log.names_report + +log.set_loglevel(config.luaotfload.loglevel) + --[[doc-- Before \TeX Live 2013 version, \LUATEX had a bug that made ofm fonts @@ -167,7 +176,8 @@ local find_vf_file = function (name) fullname = kpsefind_file(lpegmatch(p_removesuffix, name), "ovf") end if fullname then - log("loading virtual font file %s.", fullname) + report ("log", 0, "main", + "loading virtual font file %s.", fullname) end return fullname end @@ -251,7 +261,7 @@ end local context_environment = { } local push_namespaces = function () - log("push namespace for font loader") + report ("log", 1, "main", "push namespace for font loader") local normalglobal = { } for k, v in next, _G do normalglobal[k] = v @@ -264,7 +274,7 @@ local pop_namespaces = function (normalglobal, isolate) local _G = _G local mode = "non-destructive" if isolate then mode = "destructive" end - log("pop namespace from font loader -- " .. mode) + report ("log", 1, "main", "pop namespace from font loader -- " .. mode) for k, v in next, _G do if not normalglobal[k] then context_environment[k] = v @@ -279,7 +289,8 @@ local pop_namespaces = function (normalglobal, isolate) -- just to be sure: setmetatable(context_environment,_G) else - log("irrecoverable error during pop_namespace: no globals to restore") + report ("both", 0, "main", + "irrecoverable error during pop_namespace: no globals to restore") os.exit() end end @@ -312,13 +323,13 @@ loadmodule "fontloader.lua" if fonts then if not fonts._merge_loaded_message_done_ then - log [["I am using the merged fontloader here.]] - log [[ If you run into problems or experience unexpected]] - log [[ behaviour, and if you have ConTeXt installed you can try]] - log [[ to delete the file 'luaotfload-fontloader.lua' as I might]] - log [[ then use the possibly updated libraries. The merged]] - log [[ version is not supported as it is a frozen instance.]] - log [[ Problems can be reported to the ConTeXt mailing list."]] + report ("log", 0, "main", [["I am using the merged fontloader here.]]) + report ("log", 0, "main", [[ If you run into problems or experience unexpected]]) + report ("log", 0, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) + report ("log", 0, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) + report ("log", 0, "main", [[ then use the possibly updated libraries. The merged]]) + report ("log", 0, "main", [[ version is not supported as it is a frozen instance.]]) + report ("log", 0, "main", [[ Problems can be reported to the ConTeXt mailing list."]]) end fonts._merge_loaded_message_done_ = true @@ -376,7 +387,7 @@ end --- non-merge fallback scope pop_namespaces(our_environment, false)-- true) -log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) +report ("both", 0, "main", "fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) --[[doc-- @@ -409,11 +420,8 @@ add_to_callback("hpack_filter", add_to_callback("find_vf_file", find_vf_file, "luaotfload.find_vf_file") -loadmodule "log.lua" --- messages; used to be part of -override loadmodule "override.lua" --- load glyphlist on demand -logs.set_loglevel(config.luaotfload.loglevel) - --[[doc-- Now we load the modules written for \identifier{luaotfload}. @@ -535,9 +543,9 @@ request_resolvers.anon = function (specification) local exists, _ = lfsisfile(name) if exists then --- garbage; we do this because we are nice, --- not because it is correct - logs.names_report("log", 1, "load", "file %q exists", name) - logs.names_report("log", 1, "load", - "... overriding borked anon: lookup with path: lookup") + log.names_report("log", 1, "load", "file %q exists", name) + log.names_report("log", 1, "load", + "... overriding borked anon: lookup with path: lookup") specification.name = name request_resolvers.path(specification) return @@ -559,9 +567,9 @@ request_resolvers.path = function (specification) local name = specification.name local exists, _ = lfsisfile(name) if not exists then -- resort to file: lookup - logs.names_report("log", 1, "load", - "path lookup of %q unsuccessful, falling back to file:", - name) + log.names_report("log", 1, "load", + "path lookup of %q unsuccessful, falling back to file:", + name) file_resolver (specification) else local suffix = filesuffix (name) diff --git a/luaotfload-override.lua b/luaotfload-override.lua index 4363b74..e726f6f 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -7,9 +7,11 @@ if not modules then modules = { } end modules ["luaotfload-override"] = { } local findfile = resolvers.findfile -local names_report = logs.names_report local encodings = fonts.encodings +local log = luaotfload.log +local names_report = log.names_report + --[[doc-- Adobe Glyph List. diff --git a/luaotfload-parsers.lua b/luaotfload-parsers.lua index 51d251c..8060d05 100644 --- a/luaotfload-parsers.lua +++ b/luaotfload-parsers.lua @@ -38,8 +38,8 @@ local filedirname = file.dirname local io = io local ioopen = io.open -local logs = logs -local report = logs.report +local log = luaotfload.log +local report = log.names_report local string = string local stringsub = string.sub diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 6ca7d69..e791e3d 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -9,7 +9,10 @@ -- MODIFIED: 2014-01-14 13:17:04+0100 ----------------------------------------------------------------------- -local version = "2.5" --- . +luaotfload = luaotfload or { } +local version = "2.5" --- .- +luaotfload.version = version +luaotfload.self = "luaotfload-tool" --[[doc-- @@ -104,8 +107,6 @@ if not luaotfloadconfig.strip then luaotfloadconfig.strip = true end -luaotfloadconfig.self = "luaotfload-tool" - config.lualibs = config.lualibs or { } config.lualibs.verbose = false config.lualibs.prefer_merged = true @@ -141,23 +142,24 @@ require"luaotfload-basics-gen.lua" texio.write, texio.write_nl = backup.write, backup.write_nl utilities = backup.utilities -require"luaotfload-log.lua" --- this populates the logs.* namespace +require"luaotfload-log.lua" --- this populates the luaotfload.log.* namespace require"luaotfload-parsers" --- fonts.conf and request syntax require"luaotfload-database" require"alt_getopt" -local names = fonts.names - +local names = fonts.names local status_file = "luaotfload-status" local luaotfloadstatus = require (status_file) luaotfloadconfig.status = luaotfloadstatus - local sanitize_fontname = names.sanitize_fontname -local pathdata = names.path -local names_plain = pathdata.index.lua -local names_gzip = names_plain .. ".gz" -local names_bin = pathdata.index.luc +local log = luaotfload.log +local names_report = log.names_report -- TODO improve identifier + +local pathdata = names.path +local names_plain = pathdata.index.lua +local names_gzip = names_plain .. ".gz" +local names_bin = pathdata.index.luc local help_messages = { ["luaotfload-tool"] = [[ @@ -248,7 +250,7 @@ Enter 'luaotfload-tool --help' for a larger list of options. local help_msg = function (version) local template = help_messages[version] iowrite(stringformat(template, - luaotfloadconfig.self, + luaotfload.self, -- names_plain, names_gzip, names_bin, @@ -265,8 +267,8 @@ local about = [[ local version_msg = function ( ) local out = function (...) texiowrite_nl (stringformat (...)) end - out (about, luaotfloadconfig.self) - out ("%s version %q", luaotfloadconfig.self, version) + out (about, luaotfload.self) + out ("%s version %q", luaotfload.self, version) out ("revision %q", luaotfloadstatus.notes.revision) out ("database version %q", names.version) out ("Lua interpreter: %s; version %q", runtime[1], runtime[2]) @@ -681,7 +683,7 @@ local show_font_info = function (basename, askedname, detail, warnings) if nfonts > 0 then -- true type collection local subfont if askedname then - logs.names_report(true, 1, "resolve", + log.names_report(true, 1, "resolve", [[%s is part of the font collection %s]], askedname, basename) subfont = subfont_by_name(shortinfo, askedname) @@ -692,10 +694,10 @@ local show_font_info = function (basename, askedname, detail, warnings) show_full_info(fullname, subfont, warnings) end else -- list all subfonts - logs.names_report(true, 1, "resolve", + log.names_report(true, 1, "resolve", [[%s is a font collection]], basename) for subfont = 1, nfonts do - logs.names_report(true, 1, "resolve", + log.names_report(true, 1, "resolve", [[Showing info for font no. %d]], n) show_info_items(shortinfo[subfont]) if detail == true then @@ -710,7 +712,7 @@ local show_font_info = function (basename, askedname, detail, warnings) end end else - logs.names_report(true, 1, "resolve", + log.names_report(true, 1, "resolve", "Font %s not found", filename) end end @@ -735,10 +737,10 @@ action_pending.generate = false --- this is the default action local actions = { } --- (jobspec -> (bool * bool)) list actions.loglevel = function (job) - logs.set_loglevel(job.log_level) - logs.names_report("info", 3, "util", + log.set_loglevel(job.log_level) + log.names_report("info", 3, "util", "Setting log level", "%d", job.log_level) - logs.names_report("log", 2, "util", "Lua=%s", _VERSION) + log.names_report("log", 2, "util", "Lua=%s", _VERSION) return true, true end @@ -764,7 +766,7 @@ end actions.generate = function (job) local fontnames, savedname fontnames = names.update(fontnames, job.force_reload, job.dry_run) - logs.names_report("info", 2, "db", + log.names_report("info", 2, "db", "Fonts in the database: %i", #fontnames.mappings) if names.data() then return true, true @@ -777,7 +779,7 @@ actions.flush = function (job) if success then local success = names.save_lookups() if success then - logs.names_report("info", 2, "cache", "Lookup cache emptied") + log.names_report("info", 2, "cache", "Lookup cache emptied") return true, true end end @@ -793,7 +795,7 @@ local cache_directives = { actions.cache = function (job) local directive = cache_directives[job.cache] if not directive or type(directive) ~= "function" then - logs.names_report("info", 2, "cache", + log.names_report("info", 2, "cache", "Invalid font cache directive %s.", job.cache) return false, false end @@ -838,14 +840,14 @@ actions.query = function (job) end if success then - logs.names_report(false, 0, + log.names_report(false, 0, "resolve", "Font %q found!", query) if subfont then - logs.names_report(false, 0, "resolve", + log.names_report(false, 0, "resolve", "Resolved file name %q, subfont nr. %q", foundname, subfont) else - logs.names_report(false, 0, "resolve", + log.names_report(false, 0, "resolve", "Resolved file name %q", foundname) end if job.show_info then @@ -853,12 +855,12 @@ actions.query = function (job) iowrite "\n" end else - logs.names_report(false, 0, + log.names_report(false, 0, "resolve", "Cannot find %q in index.", query) - logs.names_report(false, 0, + log.names_report(false, 0, "resolve", "Hint: use the --fuzzy option to display suggestions.", query) if job.fuzzy == true then - logs.names_report(false, 0, + log.names_report(false, 0, "resolve", "Looking for close matches, this may take a while ...") local _success = names.find_closest(query, job.fuzzy_limit) end @@ -957,7 +959,7 @@ actions.list = function (job) local nmappings = #mappings if criterion == "*" then - logs.names_report(false, 1, "list", "All %d entries", nmappings) + log.names_report(false, 1, "list", "All %d entries", nmappings) for i=1, nmappings do local entry = mappings[i] local fields = get_fields(entry, asked_fields) @@ -972,12 +974,12 @@ actions.list = function (job) criterion = criterion[1] asked_fields = set_primary_field(asked_fields, criterion) - logs.names_report(false, 1, "list", "By %s", criterion) + log.names_report(false, 1, "list", "By %s", criterion) --- firstly, build a list of fonts to operate on local targets = { } if asked_value then --- only those whose value matches - logs.names_report(false, 2, "list", "Restricting to value %s", asked_value) + log.names_report(false, 2, "list", "Restricting to value %s", asked_value) for i=1, nmappings do local entry = mappings[i] if entry[criterion] @@ -1022,7 +1024,7 @@ actions.list = function (job) end end local ntargets = #targets - logs.names_report(false, 2, "list", "%d entries", ntargets) + log.names_report(false, 2, "list", "%d entries", ntargets) --- now, output the collection for i=1, ntargets do @@ -1150,7 +1152,7 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "log" then local str = optarg[n] if str then - finalizers = logs.set_logout(str, finalizers) + finalizers = log.set_logout(str, finalizers) end elseif v == "find" then action_pending["query"] = true @@ -1230,23 +1232,23 @@ local main = function ( ) -- unit -> int local actionname = action_sequence[i] local exit = false if action_pending[actionname] then - logs.names_report("log", 3, "util", "Preparing for task", + log.names_report("log", 3, "util", "Preparing for task", "%s", actionname) local action = actions[actionname] local success, continue = action(job) if not success then - logs.names_report(false, 0, "util", + log.names_report(false, 0, "util", "Could not finish task", "%s", actionname) retval = -1 exit = true elseif not continue then - logs.names_report(false, 3, "util", + log.names_report(false, 3, "util", "Task completed, exiting", "%s", actionname) exit = true else - logs.names_report(false, 3, "util", + log.names_report(false, 3, "util", "Task completed successfully", "%s", actionname) end end -- cgit v1.2.3 From 2c6feb979da6435bb9f6636a46be576f688f7f78 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 9 Feb 2014 16:54:13 +0100 Subject: [log,*] s/log.names_report()/logs.report()/g Closing #169 Signed-off-by: Philipp Gesang --- luaotfload-auxiliary.lua | 2 +- luaotfload-database.lua | 2 +- luaotfload-diagnostics.lua | 4 +-- luaotfload-features.lua | 2 +- luaotfload-letterspace.lua | 10 +++--- luaotfload-log.lua | 16 ++++----- luaotfload-main.lua | 17 +++++----- luaotfload-override.lua | 8 ++--- luaotfload-parsers.lua | 2 +- luaotfload-tool.lua | 81 ++++++++++++++++++++++------------------------ 10 files changed, 70 insertions(+), 74 deletions(-) diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index 9ab78e7..716af98 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -17,7 +17,7 @@ luaotfload.aux = luaotfload.aux or { } local aux = luaotfload.aux local log = luaotfload.log -local report = log.names_report +local report = log.report local fonthashes = fonts.hashes local identifiers = fonthashes.identifiers diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 8f603db..c69fc03 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -45,7 +45,7 @@ local stripslashes = parsers.stripslashes local splitcomma = parsers.splitcomma local log = luaotfload.log -local report = log.names_report +local report = log.report local report_status = log.names_status local report_status_start = log.names_status_start local report_status_stop = log.names_status_stop diff --git a/luaotfload-diagnostics.lua b/luaotfload-diagnostics.lua index 4ffaa06..67119de 100644 --- a/luaotfload-diagnostics.lua +++ b/luaotfload-diagnostics.lua @@ -49,9 +49,9 @@ local lpeg = require "lpeg" local C, Cg, Ct = lpeg.C, lpeg.Cg, lpeg.Ct local lpegmatch = lpeg.match -local names_report = luaotfload.log.names_report +local report = luaotfload.log.report local out = function (...) - names_report (false, 0, "diagnose", ...) + report (false, 0, "diagnose", ...) end local parsers = luaotfload.parsers diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 73edcd2..4237d71 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -49,7 +49,7 @@ function fonts.definers.getspecification(str) end local log = luaotfload.log -local report = log.names_report +local report = log.report local stringfind = string.find local stringlower = string.lower diff --git a/luaotfload-letterspace.lua b/luaotfload-letterspace.lua index a855bf3..20f29f5 100644 --- a/luaotfload-letterspace.lua +++ b/luaotfload-letterspace.lua @@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['letterspace'] = { } local log = luaotfload.log -local report = log.names_report +local report = log.report local getmetatable = getmetatable local require = require @@ -515,10 +515,10 @@ otffeatures.register { local initializecompatfontkerning = function (tfmdata, percentage) local factor = tonumber (percentage) if not factor then - names_report ("both", 0, "letterspace", - "Invalid argument to letterspace: %s (type %q), " .. - "was expecting percentage as Lua number instead.", - percentage, type (percentage)) + report ("both", 0, "letterspace", + "Invalid argument to letterspace: %s (type %q), " .. + "was expecting percentage as Lua number instead.", + percentage, type (percentage)) return end return initializefontkerning (tfmdata, factor * 0.01) diff --git a/luaotfload-log.lua b/luaotfload-log.lua index 080550a..5698c84 100644 --- a/luaotfload-log.lua +++ b/luaotfload-log.lua @@ -200,7 +200,7 @@ local level_ids = { common = 1, loading = 2, search = 3 } --[[doc-- - The names_report logger is used more or less all over luaotfload. + The report() logger is used more or less all over luaotfload. Its requirements are twofold: 1) Provide two logging channels, the terminal and the log file; @@ -224,7 +224,7 @@ local level_ids = { common = 1, loading = 2, search = 3 } --doc]]-- -local names_report = function (mode, lvl, ...) +local report = function (mode, lvl, ...) if type(lvl) == "string" then lvl = level_ids[lvl] end @@ -242,7 +242,7 @@ local names_report = function (mode, lvl, ...) end end -log.names_report = names_report +log.report = report --[[doc-- @@ -301,7 +301,7 @@ local status_start = function (low, high) or os.getenv "TERM" == "dumb" then status_writer = function (mode, ...) - names_report (mode, high, ...) + report (mode, high, ...) end return end @@ -310,7 +310,7 @@ local status_start = function (low, high) status_writer = status_logger else status_writer = function (mode, ...) - names_report (mode, high, ...) + report (mode, high, ...) end end end @@ -348,7 +348,7 @@ log.names_status_stop = status_stop --doc]]-- local texioreporter = function (message) - names_report("log", 2, message) + report ("log", 2, message) end texio.reporter = texioreporter @@ -386,10 +386,10 @@ if fonts then --- need to be running TeX if k == "unicodes" then local glyphlist = resolvers.findfile"luaotfload-glyphlist.lua" if glyphlist then - names_report("log", 1, "load", "loading the Adobe glyph list") + report ("log", 1, "load", "loading the Adobe glyph list") else glyphlist = resolvers.findfile"font-age.lua" - names_report("both", 0, "load", + report ("both", 0, "load", "loading the extended glyph list from ConTeXt") end local unicodes = dofile(glyphlist) diff --git a/luaotfload-main.lua b/luaotfload-main.lua index 35c01f2..f5f012d 100644 --- a/luaotfload-main.lua +++ b/luaotfload-main.lua @@ -148,7 +148,7 @@ end loadmodule "log.lua" --- messages; used to be part of -override local log = luaotfload.log -local report = log.names_report +local report = log.report log.set_loglevel(config.luaotfload.loglevel) @@ -387,7 +387,8 @@ end --- non-merge fallback scope pop_namespaces(our_environment, false)-- true) -report ("both", 0, "main", "fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) +report ("both", 0, "main", + "fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) --[[doc-- @@ -543,9 +544,9 @@ request_resolvers.anon = function (specification) local exists, _ = lfsisfile(name) if exists then --- garbage; we do this because we are nice, --- not because it is correct - log.names_report("log", 1, "load", "file %q exists", name) - log.names_report("log", 1, "load", - "... overriding borked anon: lookup with path: lookup") + report ("log", 1, "load", "file %q exists", name) + report ("log", 1, "load", + "... overriding borked anon: lookup with path: lookup") specification.name = name request_resolvers.path(specification) return @@ -567,9 +568,9 @@ request_resolvers.path = function (specification) local name = specification.name local exists, _ = lfsisfile(name) if not exists then -- resort to file: lookup - log.names_report("log", 1, "load", - "path lookup of %q unsuccessful, falling back to file:", - name) + report ("log", 1, "load", + "path lookup of %q unsuccessful, falling back to file:", + name) file_resolver (specification) else local suffix = filesuffix (name) diff --git a/luaotfload-override.lua b/luaotfload-override.lua index e726f6f..b75530b 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -10,7 +10,7 @@ local findfile = resolvers.findfile local encodings = fonts.encodings local log = luaotfload.log -local names_report = log.names_report +local report = log.report --[[doc-- @@ -38,11 +38,11 @@ setmetatable(fonts.encodings.agl, { __index = function (t, k) end local glyphlist = findfile "luaotfload-glyphlist.lua" if glyphlist then - names_report("log", 1, "load", "loading the Adobe glyph list") + report ("log", 1, "load", "loading the Adobe glyph list") else glyphlist = findfile "font-age.lua" - names_report("both", 0, "load", - "loading the extended glyph list from ConTeXt") + report ("both", 0, "load", + "loading the extended glyph list from ConTeXt") end local unicodes = dofile(glyphlist) encodings.agl = { unicodes = unicodes } diff --git a/luaotfload-parsers.lua b/luaotfload-parsers.lua index 8060d05..5145ca0 100644 --- a/luaotfload-parsers.lua +++ b/luaotfload-parsers.lua @@ -39,7 +39,7 @@ local io = io local ioopen = io.open local log = luaotfload.log -local report = log.names_report +local report = log.report local string = string local stringsub = string.sub diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e791e3d..35765b5 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -154,7 +154,7 @@ luaotfloadconfig.status = luaotfloadstatus local sanitize_fontname = names.sanitize_fontname local log = luaotfload.log -local names_report = log.names_report -- TODO improve identifier +local report = log.report local pathdata = names.path local names_plain = pathdata.index.lua @@ -683,9 +683,9 @@ local show_font_info = function (basename, askedname, detail, warnings) if nfonts > 0 then -- true type collection local subfont if askedname then - log.names_report(true, 1, "resolve", - [[%s is part of the font collection %s]], - askedname, basename) + report (true, 1, "resolve", + [[%s is part of the font collection %s]], + askedname, basename) subfont = subfont_by_name(shortinfo, askedname) end if subfont then @@ -694,11 +694,11 @@ local show_font_info = function (basename, askedname, detail, warnings) show_full_info(fullname, subfont, warnings) end else -- list all subfonts - log.names_report(true, 1, "resolve", - [[%s is a font collection]], basename) + report (true, 1, "resolve", + [[%s is a font collection]], basename) for subfont = 1, nfonts do - log.names_report(true, 1, "resolve", - [[Showing info for font no. %d]], n) + report (true, 1, "resolve", + [[Showing info for font no. %d]], n) show_info_items(shortinfo[subfont]) if detail == true then show_full_info(fullname, subfont, warnings) @@ -712,8 +712,7 @@ local show_font_info = function (basename, askedname, detail, warnings) end end else - log.names_report(true, 1, "resolve", - "Font %s not found", filename) + report (true, 1, "resolve", "Font %s not found", filename) end end @@ -738,9 +737,8 @@ local actions = { } --- (jobspec -> (bool * bool)) list actions.loglevel = function (job) log.set_loglevel(job.log_level) - log.names_report("info", 3, "util", - "Setting log level", "%d", job.log_level) - log.names_report("log", 2, "util", "Lua=%s", _VERSION) + report ("info", 3, "util", "Setting log level", "%d", job.log_level) + report ("log", 2, "util", "Lua=%q", _VERSION) return true, true end @@ -766,8 +764,7 @@ end actions.generate = function (job) local fontnames, savedname fontnames = names.update(fontnames, job.force_reload, job.dry_run) - log.names_report("info", 2, "db", - "Fonts in the database: %i", #fontnames.mappings) + report ("info", 2, "db", "Fonts in the database: %i", #fontnames.mappings) if names.data() then return true, true end @@ -779,7 +776,7 @@ actions.flush = function (job) if success then local success = names.save_lookups() if success then - log.names_report("info", 2, "cache", "Lookup cache emptied") + report ("info", 2, "cache", "Lookup cache emptied") return true, true end end @@ -795,8 +792,8 @@ local cache_directives = { actions.cache = function (job) local directive = cache_directives[job.cache] if not directive or type(directive) ~= "function" then - log.names_report("info", 2, "cache", - "Invalid font cache directive %s.", job.cache) + report ("info", 2, "cache", + "Invalid font cache directive %s.", job.cache) return false, false end if directive() then @@ -840,28 +837,27 @@ actions.query = function (job) end if success then - log.names_report(false, 0, - "resolve", "Font %q found!", query) + report (false, 0, "resolve", "Font %q found!", query) if subfont then - log.names_report(false, 0, "resolve", - "Resolved file name %q, subfont nr. %q", + report (false, 0, "resolve", + "Resolved file name %q, subfont nr. %q", foundname, subfont) else - log.names_report(false, 0, "resolve", - "Resolved file name %q", foundname) + report (false, 0, "resolve", + "Resolved file name %q", foundname) end if job.show_info then show_font_info (foundname, query, job.full_info, job.warnings) iowrite "\n" end else - log.names_report(false, 0, - "resolve", "Cannot find %q in index.", query) - log.names_report(false, 0, - "resolve", "Hint: use the --fuzzy option to display suggestions.", query) + report (false, 0, "resolve", "Cannot find %q in index.", query) + report (false, 0, "resolve", + "Hint: use the --fuzzy option to display suggestions.", + query) if job.fuzzy == true then - log.names_report(false, 0, - "resolve", "Looking for close matches, this may take a while ...") + report (false, 0, "resolve", + "Looking for close matches, this may take a while ...") local _success = names.find_closest(query, job.fuzzy_limit) end end @@ -959,7 +955,7 @@ actions.list = function (job) local nmappings = #mappings if criterion == "*" then - log.names_report(false, 1, "list", "All %d entries", nmappings) + report (false, 1, "list", "All %d entries", nmappings) for i=1, nmappings do local entry = mappings[i] local fields = get_fields(entry, asked_fields) @@ -974,12 +970,12 @@ actions.list = function (job) criterion = criterion[1] asked_fields = set_primary_field(asked_fields, criterion) - log.names_report(false, 1, "list", "By %s", criterion) + report (false, 1, "list", "By %s", criterion) --- firstly, build a list of fonts to operate on local targets = { } if asked_value then --- only those whose value matches - log.names_report(false, 2, "list", "Restricting to value %s", asked_value) + report (false, 2, "list", "Restricting to value %s", asked_value) for i=1, nmappings do local entry = mappings[i] if entry[criterion] @@ -1024,7 +1020,7 @@ actions.list = function (job) end end local ntargets = #targets - log.names_report(false, 2, "list", "%d entries", ntargets) + report (false, 2, "list", "%d entries", ntargets) --- now, output the collection for i=1, ntargets do @@ -1232,24 +1228,23 @@ local main = function ( ) -- unit -> int local actionname = action_sequence[i] local exit = false if action_pending[actionname] then - log.names_report("log", 3, "util", "Preparing for task", - "%s", actionname) + report ("log", 3, "util", "Preparing for task", "%s", actionname) local action = actions[actionname] local success, continue = action(job) if not success then - log.names_report(false, 0, "util", - "Could not finish task", "%s", actionname) + report (false, 0, "util", + "Could not finish task", "%s", actionname) retval = -1 exit = true elseif not continue then - log.names_report(false, 3, "util", - "Task completed, exiting", "%s", actionname) - exit = true + report (false, 3, "util", + "Task completed, exiting", "%s", actionname) + exit = true else - log.names_report(false, 3, "util", - "Task completed successfully", "%s", actionname) + report (false, 3, "util", + "Task completed successfully", "%s", actionname) end end if exit then break end -- cgit v1.2.3