Interface LogAdapter
public interface LogAdapter
Log Adapter Interface - Logging Framework Adapter
日志适配器接口 - 日志框架适配器
This interface provides additional adapter functionality for logging frameworks, such as marker conversion and message formatting.
此接口为日志框架提供额外的适配器功能,如标记转换和消息格式化。
Features | 主要功能:
- Marker conversion between OpenLog and framework-specific markers - OpenLog 与框架特定标记之间的标记转换
- Message formatting with arguments - 使用参数的消息格式化
- Feature capability detection (markers, MDC, NDC) - 功能能力检测(标记、MDC、NDC)
Usage Examples | 使用示例:
// Implement custom log adapter
public class MyLogAdapter implements LogAdapter {
@Override
public Object convertMarker(Marker marker) {
return myFramework.getMarker(marker.getName());
}
@Override
public String formatMessage(String format, Object... args) {
return MessageFormat.format(format, args);
}
}
Security | 安全性:
- Thread-safe: Implementation-dependent - 线程安全: 取决于实现
- Null-safe: No (marker/format must not be null) - 空值安全: 否(标记/格式不能为 null)
- Since:
- JDK 25, opencode-base-log V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionconvertMarker(Marker marker) Converts an OpenLog marker to the framework-specific marker.formatMessage(String format, Object... args) Formats a message with arguments.default booleanChecks if the adapter supports markers.default booleanChecks if the adapter supports MDC.default booleanChecks if the adapter supports NDC.
-
Method Details
-
convertMarker
-
formatMessage
-
supportsMarkers
default boolean supportsMarkers()Checks if the adapter supports markers. 检查适配器是否支持标记。- Returns:
- true if markers are supported - 如果支持标记返回 true
-
supportsMDC
default boolean supportsMDC()Checks if the adapter supports MDC. 检查适配器是否支持 MDC。- Returns:
- true if MDC is supported - 如果支持 MDC 返回 true
-
supportsNDC
default boolean supportsNDC()Checks if the adapter supports NDC. 检查适配器是否支持 NDC。- Returns:
- true if NDC is supported - 如果支持 NDC 返回 true
-