Return-Path: Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: (qmail 36925 invoked from network); 29 Oct 2004 19:21:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Oct 2004 19:21:58 -0000 Received: (qmail 57668 invoked by uid 500); 29 Oct 2004 19:21:55 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 57631 invoked by uid 500); 29 Oct 2004 19:21:55 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 57618 invoked by uid 99); 29 Oct 2004 19:21:55 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [12.6.96.4] (HELO ns1018.seagullsoftware.com) (12.6.96.4) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 29 Oct 2004 12:21:53 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: cvs commit: logging-log4j/tests/src/java/org/apache/log4j/helpers/mcomposer MessageComposerTest.java Date: Fri, 29 Oct 2004 15:21:49 -0400 Message-ID: <2B64219028BBFF48B3CC957EF10B58FE30994A@ns1018.SSSI.seagull.nl> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: cvs commit: logging-log4j/tests/src/java/org/apache/log4j/helpers/mcomposer MessageComposerTest.java Thread-Index: AcS9sH5Ar8dsXavRRfyfHabpC+4S+AAO6tWg From: "Gary Gregory" To: "Log4J Developers List" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Aside from whether these are good reasons or not, I do think that = creating a new namespace - "mcomposer" - is over the top, not to mention = cryptic.=20 Letting it live in ".helpers" would be fine, or if you really want a new = namespace, in ".text" or in ".helpers.text". 2c, Gary > -----Original Message----- > From: Ceki G=FClc=FC [mailto:ceki@qos.ch] > Sent: Friday, October 29, 2004 05:10 > To: Log4J Developers List > Subject: RE: cvs commit: logging- > log4j/tests/src/java/org/apache/log4j/helpers/mcomposer > MessageComposerTest.java >=20 >=20 > Hi Paul, >=20 > There are several reasons. >=20 > 1) With MessageComposer one can write: >=20 > logger.debug("My name is {}.", name); > logger.debug("My name is {}. I am {} years old", name, age); >=20 > instead of >=20 > logger.debug("My name is {0}.", name); > logger.debug("My name is {0}. I am {1} years old", name, age); >=20 > with java.text.MessageFormat. >=20 > I think the omission of the numbered parameters makes writing debug > statements quicker and easier for the user. You have to try it 4 or 5 > times to notice the difference but it becomes quite noticeable after a > short while. >=20 > 2) Since MessageComposer has a smaller scope, it should perform its > parsing duties significantly faster then java.text.MessageFormat. > Moreover, since we have access to the internals of MessageComposer, we > can modify it so that it caches its results. Thus, the next time a > given message needs to be output, we can use the parsed structure and > economize the work involved in parsing the message. >=20 > 3) MessageComposer has been already implemented and tested. >=20 > Do you think these are good reasons? >=20 > At 12:15 AM 10/29/2004, you wrote: > >Ceki, is there any reason to have MessageComposer when there is the > >java.text.MessageFormat class available from JDK1.2 that appears to = do > >exactly the same thing? (There could well be a good reason, I just = can't > >see it as yet). > > > >Just curious. > > > >cheers, > > > >Paul Smith > > > > > -----Original Message----- > > > From: ceki@apache.org [mailto:ceki@apache.org] > > > Sent: Thursday, October 28, 2004 11:13 PM > > > To: logging-log4j-cvs@apache.org > > > Subject: cvs commit: > > > logging-log4j/tests/src/java/org/apache/log4j/helpers/mcomposer > > > MessageComposerTest.java > > > > > > > > > ceki 2004/10/28 06:12:35 > > > > > > Added: tests/src/java/org/apache/log4j/helpers/mcomposer > > > MessageComposerTest.java > > > Log: > > > Unit tests for MessageComposer > > > > > > Revision Changes Path > > > 1.1 > > > logging-log4j/tests/src/java/org/apache/log4j/helpers/mcomposer/Me > > > ssageComposerTest.java > > > > > > Index: MessageComposerTest.java > > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > /* > > > * Copyright 1999,2004 The Apache Software Foundation. > > > * > > > * Licensed under the Apache License, Version 2.0 (the = "License"); > > > * you may not use this file except in compliance with the = License. > > > * You may obtain a copy of the License at > > > * > > > * http://www.apache.org/licenses/LICENSE-2.0 > > > * > > > * Unless required by applicable law or agreed to in writing, > software > > > * distributed under the License is distributed on an "AS IS" = BASIS, > > > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express > > > or implied. > > > * See the License for the specific language governing = permissions > and > > > * limitations under the License. > > > */ > > > > > > package org.apache.log4j.helpers.mcomposer; > > > > > > import org.apache.log4j.helpers.mcompose.MessageComposer; > > > > > > import junit.framework.TestCase; > > > > > > > > > /** > > > * @author Ceki Gulcu > > > * > > > */ > > > public class MessageComposerTest extends TestCase { > > > > > > public void test1Param() { > > > String result; > > > Integer i3 =3D new Integer(3); > > > > > > result =3D MessageComposer.compose("Value is {}.", i3); > > > assertEquals("Value is 3.", result); > > > > > > result =3D MessageComposer.compose("Value is {", i3); > > > assertEquals("Value is {", result); > > > > > > result =3D MessageComposer.compose("Value is {}.", null); > > > assertEquals("Value is null.", result); > > > > > > result =3D MessageComposer.compose("{} is larger than 2.", = i3); > > > assertEquals("3 is larger than 2.", result); > > > > > > result =3D MessageComposer.compose("No subst", i3); > > > assertEquals("No subst", result); > > > > > > result =3D MessageComposer.compose("Incorrect {subst", i3); > > > assertEquals("Incorrect {subst", result); > > > > > > result =3D MessageComposer.compose("Escaped \\{} subst", = i3); > > > assertEquals("Escaped \\{} subst", result); > > > > > > result =3D MessageComposer.compose("\\{Escaped", i3); > > > assertEquals("\\{Escaped", result); > > > > > > result =3D MessageComposer.compose("\\{}Escaped", i3); > > > assertEquals("\\{}Escaped", result); > > > } > > > > > > public void test2Param() { > > > String result; > > > Integer i1 =3D new Integer(1); > > > Integer i2 =3D new Integer(2); > > > > > > result =3D MessageComposer.compose("Value {} is larger than > > > {}.", i1, i2); > > > assertEquals("Value 1 is larger than 2.", result); > > > > > > result =3D MessageComposer.compose("Value {} is larger than > > > {}", i1, i2); > > > assertEquals("Value 1 is larger than 2", result); > > > > > > result =3D MessageComposer.compose("{}{}", i1, i2); > > > assertEquals("12", result); > > > result =3D MessageComposer.compose("Val1=3D{}, Val2=3D{", = i1, i2); > > > assertEquals("Val1=3D1, Val2=3D{", result); > > > } > > > } > > > > > > > > > > > > > > > = --------------------------------------------------------------------- > > > To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org > > > For additional commands, e-mail: log4j-dev-help@logging.apache.org > > > > > > > > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org > >For additional commands, e-mail: log4j-dev-help@logging.apache.org >=20 > -- > Ceki G=FClc=FC >=20 > For log4j documentation consider "The complete log4j manual" > http://www.qos.ch/shop/products/eclm/ >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-dev-help@logging.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org