I’m working on a comprehensive error handling module, and I am building the kind of “errors list” that you see in http://help.interfaceware.com/kb/692. My code looks like:
local Errs = validate.CheckAdt(MsgIn) if Errs then for i = 1, #Errs do iguana.logInfo(Errs[i]) end return true
I’m concerned, though, that if a message has multiple lines in Errs, then in the logs, I’ll see an entry for each one of those lines. Is there a way that I can aggregate the logInfo lines and put them into the logs as a block of text, rather than multiple entries of one line each?
Yes just loop through the lines and append them into one string. If performance is an issue you can use:
This is a good article I often point out new devs to talking about the issues with concatenating many many many strings together:
But in this case a simple loop like:
local R = 'Errors!\n' for i=1, #Errs do R = R..Errs[i].."\n" end iguana.logInfo(R)
Should perform fine unless you have 1000+ errors…
Should do the trick.
Ah, I was so close! I was using \r instead of \n.
That said, I’m still having a problem. The list (the one you called R) is building correctly, but it won’t write into the log. The only thing I see there is the ‘Errors!” from the initial assignment.
You must be logged in to reply to this topic.
Please don't hesitate to take anonymous feedback survey or leave us a comment.