chg: better debugging functions.

This commit is contained in:
iceman1001 2017-12-03 15:24:24 +01:00
commit c4b73c8737
2 changed files with 31 additions and 12 deletions

View file

@ -15,19 +15,29 @@ Arguments:
-o <filename> Specifies the output file. If omitted, <uid>.eml is used. -o <filename> Specifies the output file. If omitted, <uid>.eml is used.
]] ]]
local DEBUG = false
--- ---
-- A debug printout-function -- A debug printout-function
function dbg(args) local function dbg(args)
if DEBUG then if not DEBUG then return end
print("###", args)
if type(args) == 'table' then
local i = 1
while result[i] do
dbg(result[i])
i = i+1
end
else
print('###', args)
end end
end end
--- ---
-- This is only meant to be used when errors occur -- This is only meant to be used when errors occur
function oops(err) local function oops(err)
print("ERROR: ",err) print('ERROR: ',err)
return nil,err
end end
--- ---
-- Usage help -- Usage help
function help() function help()

View file

@ -16,22 +16,31 @@ Arguments:
-o <filename> Specifies the output file. If omitted, <uid>.eml is used. -o <filename> Specifies the output file. If omitted, <uid>.eml is used.
]] ]]
local DEBUG = false
------------------------------- -------------------------------
-- Some utilities -- Some utilities
------------------------------- -------------------------------
--- ---
-- A debug printout-function -- A debug printout-function
function dbg(args) local function dbg(args)
if DEBUG then if not DEBUG then return end
print("###", args)
if type(args) == 'table' then
local i = 1
while result[i] do
dbg(result[i])
i = i+1
end
else
print('###', args)
end end
end end
--- ---
-- This is only meant to be used when errors occur -- This is only meant to be used when errors occur
function oops(err) local function oops(err)
print("ERROR: ",err) print('ERROR: ',err)
return nil,err
end end
--- ---
-- Usage help -- Usage help