[coldbox-3.8.1] Using LogBox within Handlers & Models

Hi folks, just a quick knowledge check here. If I am building an application using ColdBox – which comes with WireBox & LogBox included – in which components do I need to explicitly inject LogBox and which is it already included? Bonus points for showing me where this is explained in the documentation so I can learn how to learn…

My current understanding and experience is that if I am working in a handler then I can just do the following inside my handler without explicitly injecting LogBox:

log.error("Bad stuff just happened.");

However, within a model, I need to explicitly inject it like this (or a variety of other flavors):

property name="log" inject="logbox:logger:{this}";

Then I can actually use it like I did above.

Is this accurate?

Thanks!
-Wes

You are 100% accurate

Luis Majano
CEO
Ortus Solutions, Corp

P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org
ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Objects such as handlers, plugins, and interceptors that are part of the framework all extend a parent class which extends the framework supertype (the granddaddy class)

If you look in the init() method of these components you can see what helper objects are made available, which often includes cachebox, wirebox, and the controller.

coldbox.system.Interceptor
coldbox.system.Plugin
coldbox.system.EventHandler

And ALL the methods in the super class are available as well:
coldbox.system.FrameworkSupertype

Models are not part of the framework and don’t extend any of these super classes, therefore they don’t automatically have the nice methods or properties that are available in handlers, interceptors, or plugins. So for models, you can use our injection DSL (recommended) or you can extend a system class. For instance, remote CFCs are created by the CF engine not wirebox, so they extend coldbox.system.remote.ColdBoxProxy to get access to the framework.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Fantastic, thank you both – it’s nice when you can develop with confidence that you’re on the proper path! Brad, I really appreciate the additional explanation of why this difference exists. 50 bonus points to you, sir!

Thanks again!

Wes