Class StructuredLog.Builder
java.lang.Object
cloud.opencode.base.log.enhance.StructuredLog.Builder
- Enclosing class:
StructuredLog
Structured Log Builder.
结构化日志构建器。
- Since:
- JDK 25, opencode-base-log V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionSets the exception.Adds a field.Adds multiple fields.voidlog()Logs to the default logger.voidLogs to the specified logger.Sets the marker.Sets the log message.Sets the span ID.Sets the trace ID.
-
Method Details
-
message
Sets the log message. 设置日志消息。- Parameters:
message- the message - 消息- Returns:
- this builder - 此构建器
-
field
Adds a field. 添加字段。- Parameters:
key- the field key - 字段键value- the field value - 字段值- Returns:
- this builder - 此构建器
-
fields
Adds multiple fields. 添加多个字段。- Parameters:
fields- the fields - 字段- Returns:
- this builder - 此构建器
-
exception
Sets the exception. 设置异常。- Parameters:
throwable- the exception - 异常- Returns:
- this builder - 此构建器
-
marker
Sets the marker. 设置标记。- Parameters:
marker- the marker - 标记- Returns:
- this builder - 此构建器
-
traceId
Sets the trace ID. 设置追踪 ID。- Parameters:
traceId- the trace ID - 追踪 ID- Returns:
- this builder - 此构建器
-
spanId
Sets the span ID. 设置跨度 ID。- Parameters:
spanId- the span ID - 跨度 ID- Returns:
- this builder - 此构建器
-
log
public void log()Logs to the default logger. 记录到默认日志记录器。 -
log
Logs to the specified logger. 记录到指定的日志记录器。- Parameters:
logger- the logger - 日志记录器
-