From c4b73c87376270a7b8b1ed5b053676f2b647682e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 3 Dec 2017 15:24:24 +0100 Subject: [PATCH] chg: better debugging functions. --- client/scripts/dumptoemul-mfu.lua | 22 ++++++++++++++++------ client/scripts/dumptoemul.lua | 21 +++++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/client/scripts/dumptoemul-mfu.lua b/client/scripts/dumptoemul-mfu.lua index a5c6c5e39..b308c79e5 100644 --- a/client/scripts/dumptoemul-mfu.lua +++ b/client/scripts/dumptoemul-mfu.lua @@ -15,19 +15,29 @@ Arguments: -o Specifies the output file. If omitted, .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() diff --git a/client/scripts/dumptoemul.lua b/client/scripts/dumptoemul.lua index 67520f232..1e4d6323a 100644 --- a/client/scripts/dumptoemul.lua +++ b/client/scripts/dumptoemul.lua @@ -16,22 +16,31 @@ Arguments: -o Specifies the output file. If omitted, .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