We're updating the issue view to help you get more done. 

AbstractAppender.cfc function "CanLog" fails due to text/int comparison

Description

You can't compare "FATAL" with a value of -1 to 4. It doesn't work.
Here's your code:

1 2 3 4 5 6 7 <cffunction name="canLog" output="false" access="public" returntype="any" hint="Checks wether a log can be made on this appender using a passed in level" colddoc:generic="Boolean"> <cfargument name="level" required="true" hint="The level to check if it can be logged in this Appender" colddoc:generic="numeric"/> <cfscript> return (arguments.level GTE getLevelMin() AND arguments.level LTE getLevelMax()); </cfscript> </cffunction>

The proposed change, which I have had to make in order for your code to work properly, is as follows:

1 2 3 4 5 6 7 8 9 10 11 12 <cffunction name="canLog" output="false" access="public" returntype="any" hint="Checks wether a log can be made on this appender using a passed in level" colddoc:generic="Boolean"> <cfargument name="level" required="true" hint="The level to check if it can be logged in this Appender" colddoc:generic="numeric"/> <cfscript> tmin=getLevelMin(); tmax=getLevelMax(); if (!IsNumeric(tmin)) tmin=this.logLevels.lookupAsInt(tmin); if (!IsNumeric(tmax)) tmax=this.logLevels.lookupAsInt(tmax); return (arguments.level GTE tmin AND arguments.level LTE tmax ); </cfscript> </cffunction>

Sure I could specify numeric values in the LogBox configuration, however that is a workaround that should not be required, and if it were to be required, it should be documented as such, since your documentation clearly states we can use textual values for log level representation in the configuration.

You could improve this by removing the type="numeric" colddoc attribute, and add a isNumeric() check to the arguments.level parameter, so that this function would support either text or numeric representation. That would be most excellent.

Easy peasy.

Thank you!!

Status

Assignee

Luis Majano

Reporter

Barry Durand

Time tracking

10m

Fix versions

Affects versions

2.0.0

Priority

Major