@Test public void testFillInStackTrace() throws Exception { final StackTraceRecorder[] stackTraceRecorderArray = new StackTraceRecorder[1]; mTestRecorderTree = new TestRecorderTree(stackTraceRecorderArray); Timber.plant(mTestRecorderTree); Timber.e("hoge"); StackTraceRecorder stackTraceRecorder = stackTraceRecorderArray[0]; assertNotNull(stackTraceRecorder); assertEquals("net.ypresto.timbertreeutils.StackTraceRecorderTest", stackTraceRecorder.getStackTrace()[0].getClassName()); assertEquals("testFillInStackTrace", stackTraceRecorder.getStackTrace()[0].getMethodName()); }
@Override public Throwable fillInStackTrace() { super.fillInStackTrace(); StackTraceElement[] original = getStackTrace(); Iterator<StackTraceElement> iterator = Arrays.asList(original).iterator(); List<StackTraceElement> filtered = new ArrayList<>(); while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (isTimber(stackTraceElement)) { break; } } boolean isReachedApp = false; while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (!isReachedApp && isTimber(stackTraceElement)) { continue; } isReachedApp = true; filtered.add(stackTraceElement); } setStackTrace(filtered.toArray(new StackTraceElement[filtered.size()])); return this; }
StackTraceRecorder extends Throwable { @Override public Throwable fillInStackTrace() { super.fillInStackTrace(); StackTraceElement[] original = getStackTrace(); Iterator<StackTraceElement> iterator = Arrays.asList(original).iterator(); List<StackTraceElement> filtered = new ArrayList<>(); while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (isTimber(stackTraceElement)) { break; } } boolean isReachedApp = false; while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (!isReachedApp && isTimber(stackTraceElement)) { continue; } isReachedApp = true; filtered.add(stackTraceElement); } setStackTrace(filtered.toArray(new StackTraceElement[filtered.size()])); return this; } }
StackTraceRecorder extends Throwable { @Override public Throwable fillInStackTrace() { super.fillInStackTrace(); StackTraceElement[] original = getStackTrace(); Iterator<StackTraceElement> iterator = Arrays.asList(original).iterator(); List<StackTraceElement> filtered = new ArrayList<>(); while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (isTimber(stackTraceElement)) { break; } } boolean isReachedApp = false; while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (!isReachedApp && isTimber(stackTraceElement)) { continue; } isReachedApp = true; filtered.add(stackTraceElement); } setStackTrace(filtered.toArray(new StackTraceElement[filtered.size()])); return this; } StackTraceRecorder(String detailMessage); }
StackTraceRecorder extends Throwable { @Override public Throwable fillInStackTrace() { super.fillInStackTrace(); StackTraceElement[] original = getStackTrace(); Iterator<StackTraceElement> iterator = Arrays.asList(original).iterator(); List<StackTraceElement> filtered = new ArrayList<>(); while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (isTimber(stackTraceElement)) { break; } } boolean isReachedApp = false; while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (!isReachedApp && isTimber(stackTraceElement)) { continue; } isReachedApp = true; filtered.add(stackTraceElement); } setStackTrace(filtered.toArray(new StackTraceElement[filtered.size()])); return this; } StackTraceRecorder(String detailMessage); @Override Throwable fillInStackTrace(); }
StackTraceRecorder extends Throwable { @Override public Throwable fillInStackTrace() { super.fillInStackTrace(); StackTraceElement[] original = getStackTrace(); Iterator<StackTraceElement> iterator = Arrays.asList(original).iterator(); List<StackTraceElement> filtered = new ArrayList<>(); while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (isTimber(stackTraceElement)) { break; } } boolean isReachedApp = false; while (iterator.hasNext()) { StackTraceElement stackTraceElement = iterator.next(); if (!isReachedApp && isTimber(stackTraceElement)) { continue; } isReachedApp = true; filtered.add(stackTraceElement); } setStackTrace(filtered.toArray(new StackTraceElement[filtered.size()])); return this; } StackTraceRecorder(String detailMessage); @Override Throwable fillInStackTrace();  }