Interface NDCAdapter
public interface NDCAdapter
NDC Adapter Interface - Nested Diagnostic Context Adapter
NDC 适配器接口 - 嵌套诊断上下文适配器
This interface provides an abstraction layer for NDC (stack-based context) operations, allowing different logging frameworks to provide their own implementations.
此接口为 NDC(基于栈的上下文)操作提供抽象层,允许不同的日志框架提供自己的实现。
Features | 主要功能:
- Stack-based diagnostic context abstraction - 基于栈的诊断上下文抽象
- Push/pop/peek operations - 推入/弹出/查看操作
- Configurable maximum depth - 可配置的最大深度
Usage Examples | 使用示例:
// Implement custom NDC adapter
public class MyNDCAdapter implements NDCAdapter {
@Override
public void push(String message) { ... }
@Override
public String pop() { ... }
// ... other methods
}
Security | 安全性:
- Thread-safe: Implementation-dependent - 线程安全: 取决于实现
- Null-safe: Yes (returns null when empty) - 空值安全: 是(为空时返回 null)
- Since:
- JDK 25, opencode-base-log V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the NDC stack.Returns a copy of the NDC stack.intgetDepth()Returns the depth of the NDC stack.peek()Returns the top message without removing it.pop()Pops the top message from the NDC stack.voidPushes a message onto the NDC stack.voidsetMaxDepth(int maxDepth) Sets the maximum depth of the NDC stack.voidSets the NDC stack.
-
Method Details
-
push
Pushes a message onto the NDC stack. 将消息推入 NDC 栈。- Parameters:
message- the message to push - 要推入的消息
-
pop
String pop()Pops the top message from the NDC stack. 从 NDC 栈弹出顶部消息。- Returns:
- the popped message, or null if empty - 弹出的消息,如果为空则返回 null
-
peek
String peek()Returns the top message without removing it. 返回顶部消息但不移除它。- Returns:
- the top message, or null if empty - 顶部消息,如果为空则返回 null
-
clear
void clear()Clears the NDC stack. 清空 NDC 栈。 -
getDepth
int getDepth()Returns the depth of the NDC stack. 返回 NDC 栈的深度。- Returns:
- the stack depth - 栈深度
-
setMaxDepth
void setMaxDepth(int maxDepth) Sets the maximum depth of the NDC stack. 设置 NDC 栈的最大深度。- Parameters:
maxDepth- the maximum depth - 最大深度
-
getCopyOfStack
-
setStack
-