public static LogContext registerPlaceHolderContext() { final LogContext context = new LogContext(0, 0, UUID.randomUUID().toString()); s_currentContext.set(context); return context; }
public static CallContext registerPlaceHolderContext() { final CallContext context = new CallContext(0, 0, UUID.randomUUID().toString()); s_currentContext.set(context); s_currentContextStack.get().push(context); return context; }
public static CallContext unregister() { final CallContext context = s_currentContext.get(); if (context == null) { return null; } s_currentContext.remove(); if (s_logger.isTraceEnabled()) { s_logger.trace("Unregistered: " + context); } MDC.remove("ctx"); final Stack<CallContext> stack = s_currentContextStack.get(); stack.pop(); if (!stack.isEmpty()) { s_currentContext.set(stack.peek()); } else { s_currentContext.set(null); } return context; }
protected static LogContext register(final User callingUser, final Account callingAccount, final Long userId, final Long accountId, final String contextId) { LogContext callingContext = null; if (userId == null || accountId == null) { callingContext = new LogContext(callingUser, callingAccount, contextId); } else { callingContext = new LogContext(userId, accountId, contextId); } s_currentContext.set(callingContext); MDC.put("logcontextid", " (logid: " + UuidUtils.first(contextId) + ")"); if (s_logger.isTraceEnabled()) { s_logger.trace("Registered for log: " + callingContext); } return callingContext; }
protected static CallContext register(final User callingUser, final Account callingAccount, final Long userId, final Long accountId, final String contextId) { /* Unit tests will have multiple times of setup/tear-down call to this, remove assertions to all unit test to run assert s_currentContext.get() == null : "There's a context already so what does this new register context mean? " + s_currentContext.get().toString(); if (s_currentContext.get() != null) { // FIXME: This should be removed soon. I added this check only to surface all the places that have this problem. throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString()); } */ CallContext callingContext = null; if (userId == null || accountId == null) { callingContext = new CallContext(callingUser, callingAccount, contextId); } else { callingContext = new CallContext(userId, accountId, contextId); } s_currentContext.set(callingContext); MDC.put("ctx", " (ctx: " + UuidUtils.first(contextId) + ")"); if (s_logger.isTraceEnabled()) { s_logger.trace("Registered: " + callingContext); } s_currentContextStack.get().push(callingContext); return callingContext; }