Index: lutinutil/src/test/org/codelutin/log/LutinLogTest.java diff -u lutinutil/src/test/org/codelutin/log/LutinLogTest.java:1.1 lutinutil/src/test/org/codelutin/log/LutinLogTest.java:1.2 --- lutinutil/src/test/org/codelutin/log/LutinLogTest.java:1.1 Wed Sep 13 13:27:40 2006 +++ lutinutil/src/test/org/codelutin/log/LutinLogTest.java Wed Jan 10 19:12:06 2007 @@ -23,14 +23,19 @@ * Created: 13 sept. 06 12:41:39 * * @author poussin - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Last update: $Date: 2006/09/13 13:27:40 $ + * Last update: $Date: 2007/01/10 19:12:06 $ * by : $Author: bpoussin $ */ package org.codelutin.log; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.log4j.Layout; + import junit.framework.TestCase; @@ -39,8 +44,52 @@ * */ +class Toto { + + static public void stack() throws Exception { + LutinLog log = LutinLogFactory.getLutinLog(LutinLogTest.class); + log.info("Titi called"); + + Throwable t = new Throwable(); + String fqnOfCallingClass = LutinLogTest.class.getName(); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + +/* 99*/ if(t == null) +/* 100*/ return; + String s; +/* 104*/ synchronized(sw) + { +/* 105*/ t.printStackTrace(pw); +/* 106*/ s = sw.toString(); +/* 107*/ sw.getBuffer().setLength(0); + } + + System.err.println(s); + +/* 119*/ int ibegin = s.lastIndexOf(fqnOfCallingClass); +/* 120*/ if(ibegin == -1) +/* 121*/ return; +/* 124*/ ibegin = s.indexOf(Layout.LINE_SEP, ibegin); +/* 125*/ if(ibegin == -1) +/* 126*/ return; +/* 127*/ ibegin += Layout.LINE_SEP_LEN; +/* 130*/ int iend = s.indexOf(Layout.LINE_SEP, ibegin); +/* 131*/ if(iend == -1) +/* 132*/ return; + String fullInfo = s.substring(ibegin, iend); + System.out.println(fullInfo); + } + +} + public class LutinLogTest extends TestCase { + public void testStack() throws Exception { + Toto.stack(); + } + public void testMonitor() throws Exception { LutinLog log = LutinLogFactory.getLutinLog(LutinLogTest.class);