WireBox DSL: inject named LogBox logger based on "this"

Here's something that I've wanted for a bit. (I try to space out my
off-the-wall questions so I don't drive you crazy :slight_smile: WireBox will let
me inject LogBox, the root logger, or a named logger-- but I want to
inject the appropriate named logger for the component I'm dealing
with. Of course, I can just inject LogBox and then do
LogBox.getLogger(this) in my onDiComplete(), but I'm lazy and don't
want to have that extra onDIComplete method and I don't want to type
out the class name in the cfpropery so I can still refactor easily.
I'm thinking something like so:

<cfproperty name="logger" inject="logbox:logger:this">

"This" would have to become a reserved word since if you actually
named a logger "this" that would cause problems (or at least preclude
this from functioning). Then in Builder.getLogBoxDSL(), we'd chek for
the logger name of "this" and pull the name of the component being
wired instead.

Two issues I can think of are:
1) getLogBoxDSL() is too decoupled from the rest of the injector to
have a reference to the object being wired and therefore we'd somehow
need to pass that in.
2) I realize that WireBox can be asked for an object outside of the
context of autowiring. If I just have a cfm file that grabs the
injector out of its registered scope and asks it for an instance of a
mapping that was set up using the logbox:logger:this DSL, what
category name would it use for the named logger?

If we can iron out those wrinkles, this simple enhancement would make
me a happy man (and stay true to the simplicity and usefullness of
ColdBox).

Thoughts?

~Brad

Interesting idea. Will have to look at the code and analyze but I think this could be feasible. I was thinking of altering the dsl builders to allow the incoming target just for utility purposes. This would help dsl builders in general and does not affect di.

Let me look into this.

Luis Majano
President
Ortus Solutions, Corp

how about

property name=“log” inject=“logbox:logger:{this}”

So we use {} as placeholders in the DSL?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I thought about that, I think that would be a good idea.

Ok, reworked and on dev branch. Happy Easter!!

inject=“logbox:logger:{this}”

Thinking we can expand our DSL by using {} placeholders and let the DSL builder determine what they mean. I like this

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Cool. Thanks Luis!

~Brad

Taking a look at this today Luis. So far pretty good. However,
ColdBoxDSL.cfc needs to pass in argumentCollection=arguments in the
process method for each of the sub-methods in the case statement.
Otherwise you will get an error when arguments.targetObject is not
defined.

Thanks!

~Brad