Quantcast
View Feature Request
Unique call with severity parameter
Feature #: 1750
File: LibDebugLogger
Date: 08/25/19 09:28 AM
By: IceHeart
Status: Under Review
'Seņor' Insidiator,<br>
Awesome work on the LibDebuglogger! I'm liking more and more and it's now default on a couple projects I'm working on.<br>
<br>
A small feature request:<br>
Currently, the different severity levels are separate mehtods. This is fine and good, but makes it a occasionally cumbersome if/when you have severity triggering on a variable, or to change the severity level quickly.<br>
<br>
Could you add a small 'single' method, along the lines of:<br>
<br>
<font face="Courier New">LibDebugLogger:Log(msg,sev)</font><br>
(name to be defined, may not be 'Log', whatever's appropriate :) <br>
where (pseudo):<br>
<br>
<font face="Courier New">if&nbsp;&nbsp;&nbsp;&nbsp; sev == "E" or sev==0 then libLog:Error(msg)<br>
elseif sev == "W" or sev==1 then libLog:Warn(msg)<br>
elseif sev == "I" or sev==2 then libLog:Info(msg)<br>
else libLog:Debug(msg) <br>
end<br>
</font><br>
<div><font face="Courier New"><font face="Verdana">'severity' being optional so it allows to default to 'debug' if not present.</font></font></div><br>
That way, we have a standardized call that will always be similar in format, can include severity or not, the severity can be variable-based, and it's fairly simple to change an 'info' to a 'debug', or a 'warning' to an 'error' without having to actually 'rewrite' the call:<br>
<br>
<font face="Courier New">l:Log("I'm a dummy") -- defaults to debug msg<br>
l:Log("Sirinsidiator is awesome",'I') -- info msg<br>
l:Log("I'm about to be a dummy",2) -- warn msg<br>
l:Log("I'm a bumbling dummy",'E') -- error msg<br>
l:Log("I'm a numerical dummy",0) -- another error msg<br></font><div><font face="Courier New">
l:Log("Sirinsidiator is still awesome",2) -- info msg with number</font></div><div><font face="Courier New"><br></font></div><br><div><font face="Courier New"><font face="Verdana">Thanks much!</font><br></font></div><div><font face="Courier New">
</font></div>

RSS 2.0 Feed for Favorite CommentsNotes Sort Options
By: sirinsidiator - 08/25/19 10:50 AM
I can add a method that takes the severity as a parameter, but due to the way the lib works, it will have to be the first one and can't be optional. Reason is that the log function takes any number of arguments and converts them into a message.
That aside I cannot recommend the use of literals for the severity level. You should always use the appropriate constants from the library (e.g. LibDebugLogger.LOG_LEVEL_DEBUG) in case their values change in a future version. You can always assign those to local variables with shorter names.
By: IceHeart - 08/26/19 05:20 PM
Fair point, I forgot you also accept formatting string, so 1st param would be ok. and as far as the literals, you're correct, can easily reference them with locals.