Return-Path: Delivered-To: apmail-jakarta-avalon-dev-archive@jakarta.apache.org Received: (qmail 79511 invoked by uid 500); 29 Aug 2001 05:21:50 -0000 Mailing-List: contact avalon-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: "Avalon Development" Delivered-To: mailing list avalon-dev@jakarta.apache.org Received: (qmail 79500 invoked from network); 29 Aug 2001 05:21:50 -0000 Message-ID: <001a01c1304b$4360c3a0$36094318@home.com> From: "Mircea Toma" To: "Avalon Development" References: <001401c13047$fa30adb0$36094318@home.com> Subject: Re: LogTarget factories Date: Tue, 28 Aug 2001 23:27:14 -0600 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0017_01C13018.F856C8F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0017_01C13018.F856C8F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi again, I don't know were my head was! The corrected classes are attached .... I think :) Mircea ----- Original Message ----- From: "Mircea Toma" To: "Avalon Development" Sent: Tuesday, August 28, 2001 11:03 PM Subject: Re: LogTarget factories > Hi, > > The tests for JMSTopicTargetFactory and JDBCTargetFactory are working fine. > No changes to the code are necessary. > I also updated TextMessageBuilder and created a XMLMessageBuilder that are > attached here. > > Mircea > > > ----- Original Message ----- > From: "giacomo" > To: "Avalon Development" > Sent: Sunday, August 26, 2001 11:00 PM > Subject: Re: LogTarget factories > > > > On Sun, 26 Aug 2001, Mircea Toma wrote: > > > > > Hi, > > > > > > Here are JMSTopicTargetFactory and JDBCTargetFactory classes. Tomorow I > will > > > try to test them as much as possible. If you don't like something please > let > > > me know! > > > > > > Mircea > > > > > > P.S.: Peter, I will check out how JMSTopicTarget behaves! > > > > > > > Hi Mircea > > > > Excellent. I'll commit them and you give the feedback about the tests :) > > > > Giacomo > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: avalon-dev-help@jakarta.apache.org > > > ---------------------------------------------------------------------------- ---- > --------------------------------------------------------------------- > To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: avalon-dev-help@jakarta.apache.org ------=_NextPart_000_0017_01C13018.F856C8F0 Content-Type: application/octet-stream; name="XMLMessageBuilder.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="XMLMessageBuilder.java" /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software = License * version 1.1, a copy of which has been included with this distribution = in * the LICENSE file. */ package org.apache.log.output.jms; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.log.LogEvent; import org.apache.log.format.XMLFormatter; /** * Basic message factory that stores LogEvent in Message. * * @author Mircea Toma */ public class XMLMessageBuilder implements MessageBuilder { =20 public Message buildMessage( Session session, LogEvent event ) throws JMSException { synchronized( session ) { final TextMessage message =3D session.createTextMessage(); = =20 final XMLFormatter formatter =3D new XMLFormatter(); final String xml =3D formatter.format( event ); message.setText( xml ); return message; } } =20 } ------=_NextPart_000_0017_01C13018.F856C8F0 Content-Type: application/octet-stream; name="TextMessageBuilder.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="TextMessageBuilder.java" /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software = License * version 1.1, a copy of which has been included with this distribution = in * the LICENSE file. */ package org.apache.log.output.jms; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.log.LogEvent; import org.apache.log.ContextMap; import org.apache.log.Logger; import org.apache.log.util.StackIntrospector; import java.io.StringWriter; import java.io.PrintWriter; /** * Basic message factory that stores LogEvent in Message. * * @author Peter Donald */ public class TextMessageBuilder implements MessageBuilder { private final static String TYPE_CATEGORY_STR =3D "category"; private final static String TYPE_CONTEXT_STR =3D "context"; private final static String TYPE_MESSAGE_STR =3D "message"; private final static String TYPE_TIME_STR =3D "time"; private final static String TYPE_RELATIVE_TIME_STR =3D "rtime"; private final static String TYPE_THROWABLE_STR =3D "throwable"; private final static String TYPE_PRIORITY_STR =3D "priority"; private final static String TYPE_METHOD_STR =3D "method"; private final static String TYPE_THREAD_STR =3D "thread"; public Message buildMessage( Session session, LogEvent event ) throws JMSException { synchronized( session ) { final TextMessage message =3D session.createTextMessage(); message.setText( event.getMessage() ); message.setStringProperty(TYPE_PRIORITY_STR, = event.getPriority().getName()); =20 message.setStringProperty(TYPE_CATEGORY_STR, = event.getCategory()); =20 message.setLongProperty(TYPE_TIME_STR, event.getTime()); message.setLongProperty(TYPE_RELATIVE_TIME_STR, = event.getRelativeTime()); message.setStringProperty(TYPE_METHOD_STR, getMethod( event = ) ); =20 message.setStringProperty(TYPE_THREAD_STR, getThread( event = ) ); message.setStringProperty(TYPE_THROWABLE_STR, getStackTrace( = event ) );=20 return message; } } =20 protected String getMethod( final LogEvent event) { final ContextMap map =3D event.getContextMap(); if( null !=3D map ) { final Object object =3D map.get( "method" ); if( null !=3D object ) { return object.toString(); } } final String result =3D StackIntrospector.getCallerMethod( = Logger.class ); if( null =3D=3D result ) { return "UnknownMethod"; } return result; } protected String getThread( final LogEvent event ) { final ContextMap map =3D event.getContextMap(); if( null !=3D map ) { final Object object =3D map.get( "thread" ); if( null !=3D object ) { return object.toString(); } } return Thread.currentThread().getName(); } =20 protected String getStackTrace( final LogEvent event ) { =20 final Throwable throwable =3D event.getThrowable(); final String result; =20 if ( null !=3D throwable ) { final StringWriter stringWriter =3D new StringWriter(); final PrintWriter printWriter =3D new PrintWriter( = stringWriter ); throwable.printStackTrace( printWriter ); result =3D stringWriter.getBuffer().toString(); = =20 } else=20 { result =3D ""; } =20 return result; } } ------=_NextPart_000_0017_01C13018.F856C8F0 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: avalon-dev-help@jakarta.apache.org ------=_NextPart_000_0017_01C13018.F856C8F0--