libs/logger.lua

Sun, 30 May 2010 02:47:19 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 30 May 2010 02:47:19 +0100
changeset 75
f5ac4e39e84f
parent 5
93970910d064
child 127
8f831f259cea
permissions
-rw-r--r--

verse.plugins.session: Only negotiate session when support is advertised by the server, and not marked as optional (saves a round-trip in a lot of cases)

local print = print
local select, tostring = select, tostring;
module "logger"

local function format(format, ...)
	local n, maxn = 0, #arg;
	return (format:gsub("%%(.)", function (c) if c ~= "%" and n <= maxn then n = n + 1; return tostring(arg[n]); end end));
end

local function format(format, ...)
	local n, maxn = 0, select('#', ...);
	local arg = { ... };
	return (format:gsub("%%(.)", function (c) if n <= maxn then n = n + 1; return tostring(arg[n]); end end));
end

function init(name)
	return function (level, message, ...)
		print(level, format(message, ...));
	end
end

return _M;

mercurial