On Aug 7, 2007, at 9:10 PM, Karan Malhi wrote:
Submitted the patch. It is OPENEJB-627 . Discovered some more Loggers
:) . I have added documentationi to use LogCategory createChild()
method sparingly as this could again cause anyone to create a logger
like
Logger logger = Logger.getInstance
(LogCategory.OPENEJB,"org.apache.openejb");
Logger logger2 = logger.getInstance("someChild");
But, I think it is a good addition, as you will see in the patch, it
was used immediately.
Excellent! I'll check it out now!
You're really cooking, Karan.
-David
On 8/7/07, David Blevins <[EMAIL PROTECTED]> wrote:
On Aug 7, 2007, at 4:47 PM, Karan Malhi wrote:
Crazy. I had a similar thought (just using enums)
Thats funny, when I was thinking about this, I originally started
thinking with enums.
:)
So I can see some appeal to the idea. I guess if we used old
school
enums as you propose we could make it work. We just need some nice
way to create the "sub categories". Maybe we could tuck the
creation
of the non static final (the dynamically created) LogCategories
away
as in..
// Standard setup part
private static final Logger log = Logger.getInstance
(LogCategory.OPENEJB_DEPLOY, Foo.class);
// Now later i need to do something app specific
Logger appLog = log.getLogger("mySuperApp");
-- - - -- - - - - - -
Under the covers it might just be something like:
return Logger.getInstance(this.logCategory.createChild
("mySuperApp", this.packageName);
Very cool, I was thinking how to do it, the above seems a very
elegant
solution. I was just thinking about the following where we pass in a
string.
Logger appLog = log.getLogger("mySuperApp");
Is it possible to pass in some sort of custom object, like a
ModuleId
object or something.
So, the above could look like
Logger appLog = log.getLogger(ModuleId.get("mySuperApp"));
And ModuleId could be something like
public final class ModuleId {
private String name;
private ModuleId(String name){ this.name = name;}
public ModuleId get(String name){return new ModuleId(name);}
}
I know that the above is probably slightly more convoluted than
using
a String, but I was thinking that a custom object would keep the
Logging API "strict,tight and unambiguous".
I think we have it right where we want it. Tight enough that no
logger can be created not under "OpenEJB." but with enough wiggle
room for future creativity -- whatever that may be.
-David
--
Karan Singh Malhi