public void push(PropertyPath path) { pathStack.addFirst( path ); MDC.put( MDC_KEY, extractFullPath( path ) ); }
public void pop() { pathStack.removeFirst(); PropertyPath newHead = pathStack.peekFirst(); MDC.put( MDC_KEY, extractFullPath( newHead ) ); } }
public Object processInvocation(final InterceptorContext context) throws Exception { final Map<String, Object> mdc = MDC.getMap(); if (mdc != null) { for (String str : mdc.keySet()) { MDC.remove(str); } } final StoredLogDiagnosticContext data = (StoredLogDiagnosticContext) context.getPrivateData(KEY); context.putPrivateData(KEY, null); if (data != null && data.getMdc() != null) { for (Map.Entry<String, Object> entry : data.getMdc().entrySet()) { MDC.put(entry.getKey(), entry.getValue()); } final int depth = NDC.getDepth(); NDC.push(data.getNdc()); try { return context.proceed(); } finally { NDC.setMaxDepth(depth); for (String str : MDC.getMap().keySet()) { MDC.remove(str); } } } return context.proceed(); } }
public void put(String key, String val) { MDC.put(key, val); }
@Override public void putMdc(String key, String val) { if (val == null) { MDC.remove(key); } else { MDC.put(key, val); } }
/** * {@inheritDoc} */ @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { MDC.put("username", authentication.getPrincipal()); } filterChain.doFilter(servletRequest, servletResponse); MDC.remove("username"); }
/** * {@inheritDoc} */ @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { MDC.put("username", authentication.getPrincipal()); } filterChain.doFilter(servletRequest, servletResponse); MDC.remove("username"); }
@Override public void push(NavigablePath navigablePath) { assert navigablePath != null; internalStack.push( navigablePath ); MDC.put( MDC_KEY, navigablePath.getFullPath() ); }
private void logAfterComplete(ChannelFuture future, AccessLoggingHeader header, int responseBytes, String status) { String remoteAddress = ((InetSocketAddress)future.channel().remoteAddress()).getHostString(); future.addListener(f -> { // Duration long duration; if (header.requestStart == null) { duration = -1; } else { duration = ChronoUnit.MILLIS.between(header.requestStart, ZonedDateTime.now()); } MDC.clear(); MDC.put("address", remoteAddress); MDC.put("user", checkForNull(header.principalName)); MDC.put("method", checkForNull(header.getOp())); MDC.put("protocol", checkForNull(HotRodVersion.forVersion(header.getVersion()))); MDC.put("status", checkForNull(status)); MDC.put("responseSize", responseBytes); MDC.put("requestSize", header.requestBytes); MDC.put("duration", duration); log.tracef("/%s/%s", checkForNull(header.getCacheName()), checkForNull(header.key)); }); }
public static ProcessController start(String[] args) throws IOException { MDC.put("process", "process controller");
public static ProcessController start(String[] args) throws IOException { MDC.put("process", "process controller");
public static ProcessController start(String[] args) throws IOException { MDC.put("process", "process controller");
MDC.put("process", "host controller");
MDC.put("process", "host controller");
MDC.put("process", "host controller");
public NavigablePath pop() { assert !internalStack.isEmpty(); final NavigablePath previous = internalStack.pop(); final NavigablePath newHead = internalStack.getCurrent(); if ( TRACE_ENABLED ) { log.tracef( "Popped Navigable(%s), new head = NavigablePathStack(%s)", previous.getLocalName(), newHead == null ? NO_PATH : newHead.getFullPath() ); } final String mdcRep = newHead == null ? NO_PATH : newHead.getFullPath(); MDC.put( MDC_KEY, mdcRep ); return previous; }