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.
]]
local DEBUG = false
---
-- A debug printout-function
function dbg(args)
if DEBUG then
print("###", args)
local function dbg(args)
if not DEBUG then return end
if type(args) == 'table' then
local i = 1
while result[i] do
dbg(result[i])
i = i+1
end
else
print('###', args)
end
end
---
-- This is only meant to be used when errors occur
function oops(err)
print("ERROR: ",err)
local function oops(err)
print('ERROR: ',err)
return nil,err
end
---
-- Usage help
function help()

View file

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