webmcp
changeset 350:e00d11c12b68
trace.debug(...) now handles nil values properly
author | jbe |
---|---|
date | Thu Mar 26 12:26:00 2015 +0100 (2015-03-26) |
parents | 8cf6d927d074 |
children | b1748c6c3c89 |
files | framework/env/trace/debug.lua |
line diff
1.1 --- a/framework/env/trace/debug.lua Thu Mar 26 12:25:19 2015 +0100 1.2 +++ b/framework/env/trace/debug.lua Thu Mar 26 12:26:00 2015 +0100 1.3 @@ -1,19 +1,21 @@ 1.4 --[[-- 1.5 -trace.debug(...) 1.6 - ... -- messages to be inserted into the trace log 1.7 +trace.debug( 1.8 + value1, -- value to be converted to a string and included in the debug output 1.9 + value2, -- another value to be converted to a string and included in the debug output 1.10 + ... 1.11 +) 1.12 1.13 1.14 -This function can be used to include debug output in the trace log. 1.15 +This function can be used to include debug output in the trace log. Each argument is converted to a string (using tostring(...)) and all results are concatenated with a single space character between them. 1.16 1.17 --]]-- 1.18 1.19 function trace.debug(...) 1.20 if not trace._disabled then 1.21 - local message = "" 1.22 - local arg = {...} 1.23 - for i= 1,#arg,1 do 1.24 - message = message..tostring(arg[i]).." " 1.25 + local values = {} 1.26 + for i = 1, select("#", ...) do 1.27 + values[i] = tostring((select(i, ...))) 1.28 end 1.29 - trace._new_entry{ type = "debug", message = message } 1.30 + trace._new_entry{ type = "debug", message = table.concat(values, " ") } 1.31 end 1.32 end