Bear also in mind that if you are logging something, then it may be less efficient to say:

String pattern = "You have %{0} items left";
String message = format.pattern(1); // or similar syntax such as TextFormat?
log(message);


than it would be to say

String pattern = "You have %{0} items left";
log(pattern,1);

That way, the logger can take advantage of the fact that it's a message format, and not do any applications until the message needs logging, and when it does, it doesn't need to convert everything to one string first, but can write out the template as three separate log messages (log("You have "); log("1"); log (" items left");)

Alex.

On Tuesday, Aug 19, 2003, at 13:17 Europe/London, Alan Cabrera wrote:

I'm a big fan of formatting a message outside an exception class. The
reason for this is that many times I want to log the error message before I
throw an exception. Also, creating all these factory-like classes for every
exception seems daunting. To be sure, we could create something even more
sophisticated but at the expense of obfuscating the code a bit.


With that said, this is something that must be resolved now because it is
very difficult to go back and properly i18n the code because everyone is
always on to the next big thing. IMHO, this is much more important than the
package discussion that seems to be dragging on right now; not that the
package issue is not important too.



Reply via email to