The need to have `<http://log.info|log.info>()` su...
# box-products
r
The need to have
<http://log.info|log.info>()
surrounded by a
log.canInfo()
has been noted as no longer required in the ColdBox 7 release notes. Is this a feature of ColdBox 7 or LogBox 7, for sites that don't use ColdBox?
a
As I understand it you could always do:
<http://log.info|log.info>( "This is a log message", data );
even when info was disabled. The advantage of doing:
Copy code
if( log.canInfo() ){
  <http://log.info|log.info>( "This is a log message", data );
}
Was so that you could not run that bit of code if it was expensive to do so.
r
if it was expensive to do so
Yes, that's what I've always understood but not really understood what "_expensive_" actually meant. I assume they've managed to remove the expense but has that been achieved at the ColdBox end, as referenced, or the LogBox end, not mentioned in the docs.
a
Just checked the code and logbox does the check inside logMessage https://github.com/ColdBox/coldbox-platform/blob/v6.9.0/system/logging/Logger.cfc#L348
(that's on v6.9)
By Expensive it was if you had to I dunno - serialise an object or get the stack trace so that you could log it.
e
The expensive bit was serializing the second argument.
a
Yay - I was right (1st time for everything!). I should quit now.
e
You can and should still use the can methods if you do extra processing for the log outside of serialization.
a
What ColdBox 7 gives you (AFAIK) is that you can do
<http://log.info|log.info>( () => "This is a log message", data )
which does not call the anonymous function if logging is not enabled.
r
Thank you both. So looking at that v6.9 code in that area, nothing has changed in v7.0 except the closure detection. So to answer my original question, this is a feature of LogBox, not exclusive to the ColdBox implementation of LogBox, which would make sense as LogBox is built into ColdBox. Maybe that feature could be noted when the LogBox 7 release notes are written?
💯 1