On Tue, 19 Aug 2003, Cabrera, Alan wrote:
> > 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");)
>
> Good point. In OpenEJB we have a Messages class to simplify i18n messages
> and a logger that gives one a finer degree of control over i18n formatting.
>
> Concerning your statement about writing out the template as three separate
> log messages, I do not see the advantage of this since the format seems to
> work just fine and it seems to me that the logger would write the three
> pieces on three lines.
Perhaps I should have made myself a bit clearer; it wasn't necessarily
calling the log method of the logger. Rather, I should have said that the
logger can do a println statement, instead of building a temporary
StringBuffer (which is in effect what the java.text format does)
class Logger {
Writer out;
logString pattern, int i) {
//parsepattern
StringBuffer buffer = new StringBuffer();
buffer.add(firstPartOfPattern);
buffer.add(String.valueOf(i));
buffer.add(secondPartOfPattern);
out.write(buffer.toString());
out.writeln();
}
}
class Logger {
Writer out;
logString pattern, int i) {
//parsepattern
out.write(firstPartOfPattern);
out.write(String.valueOf(i));
out.write(secondPartOfPattern);
out.writeln();
}
}
/***************************************************************\
|* Alex Blewitt * Hug, and the world hugs with you *|
|* [EMAIL PROTECTED] * *|
|* Mobile: +44 7966 158 647 * Spread a little happiness *|
\***************************************************************/