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