@Override public void start() { tpc.start(); super.start(); }
@Override public void start() { throwableProxyConverter.start(); started = true; }
@Override public void start() { throwableProxyConverter.start(); started = true; }
@Override public void start() { tpc.start(); super.start(); }
@Override public void start() { tpc.start(); super.start(); }
@Override public void start() { tpc.start(); super.start(); }
@Override public void start() { tpc.start(); super.start(); }
@Override public void start() { if (this.layout == null) { PatternLayout patternLayout = new PatternLayout(); patternLayout.setContext(context); patternLayout.setPattern("%m %n"); patternLayout.start(); this.layout = patternLayout; } if (this.hostName == null || this.hostName.trim().isEmpty()) { try { this.hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { this.hostName = "localhost"; } } createGelfClient(); throwableConverter.start(); super.start(); }
@Before public void setUp() throws Exception { converter.setContext(context); converter.start(); }
@Before public void setUp() throws Exception { tpc.setContext(lc); tpc.start(); }
@Test public void withShortArgument() throws Exception { final Throwable t = TestHelper.makeNestedException(0); t.printStackTrace(pw); final ILoggingEvent le = createLoggingEvent(t); final List<String> options = Arrays.asList("short"); tpc.setOptionList(options); tpc.start(); final String result = tpc.convert(le); final BufferedReader reader = new BufferedReader(new StringReader(result)); assertTrue(reader.readLine().contains(t.getMessage())); assertNotNull(reader.readLine()); assertNull("Unexpected line in stack trace", reader.readLine()); }
@Test public void withArgumentOfOne() throws Exception { final Throwable t = TestHelper.makeNestedException(0); t.printStackTrace(pw); final ILoggingEvent le = createLoggingEvent(t); final List<String> optionList = Arrays.asList("1"); tpc.setOptionList(optionList); tpc.start(); final String result = tpc.convert(le); final BufferedReader reader = new BufferedReader(new StringReader(result)); assertTrue(reader.readLine().contains(t.getMessage())); assertNotNull(reader.readLine()); assertNull("Unexpected line in stack trace", reader.readLine()); }
@Test public void skipSelectedLine() throws Exception { String nameOfContainingMethod = "skipSelectedLine"; //given final Throwable t = TestHelper.makeNestedException(0); t.printStackTrace(pw); final ILoggingEvent le = createLoggingEvent(t); tpc.setOptionList(Arrays.asList("full", nameOfContainingMethod)); tpc.start(); //when final String result = tpc.convert(le); //then assertThat(result, is(not(emptyString()))); assertThat(result, not(containsString(nameOfContainingMethod))); }
@Test public void shouldLimitTotalLinesExcludingSkipped() throws Exception { //given final Throwable t = TestHelper.makeNestedException(0); t.printStackTrace(pw); final ILoggingEvent le = createLoggingEvent(t); tpc.setOptionList(Arrays.asList("3", "shouldLimitTotalLinesExcludingSkipped")); tpc.start(); //when final String result = tpc.convert(le); //then String[] lines = result.split(CoreConstants.LINE_SEPARATOR); assertThat(lines, Matchers.<String>arrayWithSize(3 + 1)); }
private void handleThrown(JSONObject logstashEvent, ILoggingEvent loggingEvent) { if (loggingEvent.getThrowableProxy() != null) { if (loggingEvent.getThrowableProxy().getClassName() != null) { logstashEvent.put(LayoutFields.EXCEPTION_CLASS, loggingEvent.getThrowableProxy().getClassName()); } if (loggingEvent.getThrowableProxy().getMessage() != null) { logstashEvent.put(LayoutFields.EXCEPTION_MESSAGE, loggingEvent.getThrowableProxy().getMessage()); } ThrowableProxyConverter converter = new RootCauseFirstThrowableProxyConverter(); converter.setOptionList(Arrays.asList("full")); converter.start(); String stackTrace = converter.convert(loggingEvent); logstashEvent.put(LayoutFields.STACK_TRACE, stackTrace); } }