[slf4j-dev] svn commit: r461 - slf4j/trunk/src/java/org/slf4j/impl
Ceki Gülcü
listid at qos.ch
Thu Dec 22 19:46:11 CET 2005
At 10:00 AM 12/21/2005, Cédrik LIME wrote:
>There are a couple of annoying glitches with said code though:
>1. unless I am abused, parsing stops at the first 'invalid
>DELIM_START/DELIM_STOP pair', i.e. "{blah} {}" or "{\\}". Shouldn't we
>continue
>parsing in search of a good delimiter pair?
I don't think that is the case but I'll make sure of it with test cases.
>2. what if I want to pass in an Object[] as an argument to the log
>message? For
>example:
> Object[] myArray = new Integer[] {new Integer(1)};
> log.debug("Array is: {}", myArray);
>In this case, I am afraid formatted string will be "Array is: 1" instead of
>"Array is: [[java.lang.Integer(1)".
That's a little tricky. In the hopefully rare case where the user really
wanted to print the array and not its contents, she could write:
Object[] myArray = new Integer[] {new Integer(1)};
log.debug("Array is: {}", (Object) myArray);
note the cast to Object. Admittedly, intuitive, it is not.
>3. you still need to modify all Logger classes for this code to be effective!
Oh, yes. :-)
>FYI, I came up with following code yesterday (didn't post it as I didn't
>have a
>chance to thoroughly test it): it iterates over the messagePattern delimiter
>pairs instead of the arguments array.
>Note that I still have to handle the case "one {} and an Object[] arg"
>(previous
>case 2).
>
> Cédrik
Cédrik, thanks for the code. It's a pleasure to see patches coming in. The
two versions of code (mine and yours) are very similar. For the sake of
simplicity, I'll stick with what I've written, unless your version turns
out to be simpler. :-)
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
Improve your Sudoku skills at http://www.sudoku-grok.com/
More information about the slf4j-dev
mailing list