Class LogContext.ContextSnapshot

java.lang.Object
cloud.opencode.base.log.context.LogContext.ContextSnapshot
Enclosing class:
LogContext

public static final class LogContext.ContextSnapshot extends Object
Context Snapshot - Immutable snapshot for async propagation. 上下文快照 - 用于异步传播的不可变快照。
Since:
JDK 25, opencode-base-log V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • ContextSnapshot

      public ContextSnapshot(Map<String,String> mdcContext)
      Creates a new context snapshot. 创建新的上下文快照。
      Parameters:
      mdcContext - the MDC context - MDC 上下文
  • Method Details

    • mdcContext

      public Map<String,String> mdcContext()
      Returns the MDC context. 返回 MDC 上下文。
      Returns:
      the MDC context - MDC 上下文
    • runWith

      public void runWith(Runnable runnable)
      Executes a task with this context. 使用此上下文执行任务。
      Parameters:
      runnable - the task - 任务
    • callWith

      public <T> T callWith(Supplier<T> supplier)
      Executes a task with this context and returns the result. 使用此上下文执行任务并返回结果。
      Type Parameters:
      T - the result type - 结果类型
      Parameters:
      supplier - the task - 任务
      Returns:
      the result - 结果
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object