From 1e04ecc2c4918448e8ff30a2e6363025267cac79 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 21 Apr 2013 00:55:45 +0200 Subject: add rudimentary verbosity switch --- lualibs.lua | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'lualibs.lua') diff --git a/lualibs.lua b/lualibs.lua index 4f354b5..f126fb7 100644 --- a/lualibs.lua +++ b/lualibs.lua @@ -11,16 +11,13 @@ local lualibs_module = { license = "See ConTeXt's mreadme.pdf for the license", } ---- TODO should be set in some global config -prefer_merged = true ---false -local load_extended = true ---false +_G.config = _G.config or { } +_G.config.lualibs = _G.config.lualibs or { } +local lualibs = _G.config.lualibs -if config and config.lualibs then - local cl_prefer_merged = config.lualibs.prefer_merged - local cl_load_extended = config.lualibs.load_extended - if cl_prefer_merged ~= nil then prefer_merged = cl_prefer_merged end - if cl_load_extended ~= nil then load_extended = cl_load_extended end -end +if lualibs.prefer_merged == nil then lualibs.prefer_merged = true end +if lualibs.load_extended == nil then lualibs.load_extended = true end +lualibs.verbose = lualibs.verbose == true or false local lpeg, kpse = lpeg, kpse @@ -29,11 +26,24 @@ local lpegmatch = lpeg.match local stringformat = string.format local find_file, error, warn, info -if luatexbase and luatexbase.provides_module then - error, warn, info = luatexbase.provides_module(lualibs_module) -else - error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub +do + local _error, _warn, _info + if luatexbase and luatexbase.provides_module then + _error, _warn, _info = luatexbase.provides_module(lualibs_module) + else + _error, _warn, _info = texio.write_nl, texio.write_nl, texio.write_nl -- stub + end + + -- if lualibs.verbose then + if lualibs.verbose then + error, warn, info = _error, _warn, _info + else + local dummylogger = function ( ) end + error, warn, info = _error, dummylogger, dummylogger + end + lualibs.error, lualibs.warn, lualibs.info = error, warn, info end + if luatexbase and luatexbase.find_file then find_file = luatexbase.find_file else @@ -51,6 +61,7 @@ loadmodule = _G.loadmodule or function (name, t) dofile(filepath) return true end +lualibs.loadmodule = loadmodule --[[doc-- The separation of the “basic” from the “extended” sets coincides with -- cgit v1.2.3