Uploaded image for project: 'LogBox'
  1. LOGBOX-21

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

    Details

      Description

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

      <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:

      <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!!

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                lmajano Luis Majano
                Reporter:
                ensemblebd Barry Durand
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 10m
                  10m
                  Remaining:
                  Remaining Estimate - 10m
                  10m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified