Return-Path: Delivered-To: apmail-incubator-geronimo-dev-archive@incubator.apache.org Received: (qmail 90919 invoked by uid 500); 20 Aug 2003 01:25:35 -0000 Mailing-List: contact geronimo-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-dev@incubator.apache.org Received: (qmail 90768 invoked from network); 20 Aug 2003 01:25:30 -0000 Received: from msexchange00.multex.com (204.255.41.71) by daedalus.apache.org with SMTP; 20 Aug 2003 01:25:30 -0000 Received: by msexchange00 with Internet Mail Service (5.5.2653.19) id ; Tue, 19 Aug 2003 14:35:32 -0400 Message-ID: <79B184B0417FD41184DB00508BA540B8058C30E7@corpmail01> From: "Cabrera, Alan" To: "'geronimo-dev@incubator.apache.org'" Subject: RE: [i18n] Hardcoded message strings Date: Tue, 19 Aug 2003 14:34:01 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N > -----Original Message----- > From: Alex Blewitt [mailto:Alex.Blewitt@ioshq.com] > > 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");) 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. Static final Messages _msg = new Messages( "org.openejb.util.resources" ); if ( initialized ) { String msg = messages.message( "startup.alreadyInitialzied", new Date() ); logger.error( msg ); throw new OpenEJBException( msg ); } else { logger.i18n.info( "startup.starting", new Date() ); } The former message needs to be formatted anyway, since we're throwing an exception. The latter call to the logger will not format the message unless info logging is turned on. 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. Regards, Alan ---------------------------------------------------------------- Visit our Internet site at http://www.reuters.com Get closer to the financial markets with Reuters Messaging - for more information and to register, visit Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of The Reuters Group.