View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.pattern;
11  
12  import ch.qos.logback.classic.spi.ClassPackagingData;
13  import ch.qos.logback.classic.spi.LoggingEvent;
14  import ch.qos.logback.classic.spi.StackTraceElementProxy;
15  import ch.qos.logback.classic.spi.ThrowableDataPoint;
16  import ch.qos.logback.classic.spi.ThrowableProxy;
17  
18  public class ExtendedThrowableProxyConverter extends ThrowableProxyConverter {
19  
20    @Override
21    protected void extraData(StringBuilder builder, ThrowableDataPoint tdp) {
22  
23      StackTraceElementProxy step = tdp.getStackTraceElementProxy();
24      if (step != null) {
25        ClassPackagingData pi = step.getClassPackagingData();
26        if (pi != null) {
27          builder.append(" [").append(pi.getCodeLocation()).append(':').append(
28              pi.getVersion()).append(']');
29        }
30      }
31    }
32  
33    protected void prepareLoggingEvent(LoggingEvent event) {
34      ThrowableProxy tp = event.getThrowableProxy();
35      tp.calculatePackagingData();
36    }
37  
38  }