@Override public String toString() { StringBuilder sb = new StringBuilder(); for (Tuple<String, String> e : getMDC()) { sb.append(e.getFirst()); sb.append(": "); sb.append(e.getSecond()); sb.append("\n"); } return sb.toString(); } }
protected <E extends Entity> void traceChange(E entity) { if (!traceOptimisticLockErrors) { return; } IndexTrace trace = new IndexTrace(); trace.threadName = Thread.currentThread().getName(); trace.id = entity.getId(); trace.type = entity.getClass().getName(); trace.timestamp = System.currentTimeMillis(); trace.mdc = CallContext.getCurrent().getMDC(); trace.stackTrace = Thread.currentThread().getStackTrace(); traces.put(trace.type + "-" + trace.id, trace); }
private static ExecutionPoint snapshot(boolean fast) { ExecutionPoint result = new ExecutionPoint(); result.threadName = Thread.currentThread().getName(); result.stacktraceHolder = new Exception(); if (!fast) { result.mdc = CallContext.getCurrent().getMDC(); } return result; }
for (Tuple<String, String> t : CallContext.getCurrent().getMDC()) { msg.append(t.getFirst()).append(": ").append(t.getSecond()).append("\n");
private void notifyHandlers(HandledException result) { // Injector might not have run yet if (handlers == null || Boolean.TRUE.equals(frozen.get())) { return; } try { frozen.set(Boolean.TRUE); String location = computeLocation(result); for (ExceptionHandler handler : handlers) { try { handler.handle(new Incident(log.getName(), location, CallContext.getCurrent().getMDC(), result)); } catch (Exception e) { // Just log the exception - anything else might call a rather long infinite loop LOG.SEVERE(new Exception(Strings.apply( "An error occurred while calling the ExceptionHandler: %s - %s (%s)", handler, e.getMessage(), e.getClass().getName()), e)); } } } finally { frozen.set(Boolean.FALSE); } }
output.line("Mapped Diagnostic Context"); output.separator(); for (Tuple<String, String> e : cc.get().getMDC()) { output.apply("%-20s %59s", e.getFirst(), e.getSecond());