Hi all! I saw a thread asking about how much debug to spew out and when (link) and since I am using a different method than everything suggested, I wanted to see what you all thought. Would this end up performing well?
What I do is I have a global debug variable. I also have a utilities file/module that I normally use throughout my code. One of the functions in this utilities module is a custom print function…
--Print function - Uses globally defined 'debugOn' boolean -- Parameters -- caller: The object or function that called this print function -- output: The text string to be output to the console -- debugOverwrite: Optional boolean that overwrites the global 'debugOn' function M.print(caller, output, debugOverwrite) if output==nil then return false; end if debugOn or debugOverwrite then local c = caller if c==nil then c=""; end print( c .. ": " .. output ) return true end return false end
I then use that print function throughout my code…
local utils = require("Utils") ... utils.print( \_sceneName, "my debug message" ) -- or if I want a specific print statement even during release... utils.print( \_sceneName, "my debug message", true )
This works fine and is easy for me to manage. I can turn all debug off by switching the global debug to false. My question is mainly performance related. Thanks in advance!
