Class StructuredLog.Builder

java.lang.Object
cloud.opencode.base.log.enhance.StructuredLog.Builder
Enclosing class:
StructuredLog

public static final class StructuredLog.Builder extends Object
Structured Log Builder. 结构化日志构建器。
Since:
JDK 25, opencode-base-log V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • message

      public StructuredLog.Builder message(String message)
      Sets the log message. 设置日志消息。
      Parameters:
      message - the message - 消息
      Returns:
      this builder - 此构建器
    • field

      public StructuredLog.Builder field(String key, Object value)
      Adds a field. 添加字段。
      Parameters:
      key - the field key - 字段键
      value - the field value - 字段值
      Returns:
      this builder - 此构建器
    • fields

      public StructuredLog.Builder fields(Map<String,Object> fields)
      Adds multiple fields. 添加多个字段。
      Parameters:
      fields - the fields - 字段
      Returns:
      this builder - 此构建器
    • exception

      public StructuredLog.Builder exception(Throwable throwable)
      Sets the exception. 设置异常。
      Parameters:
      throwable - the exception - 异常
      Returns:
      this builder - 此构建器
    • marker

      public StructuredLog.Builder marker(Marker marker)
      Sets the marker. 设置标记。
      Parameters:
      marker - the marker - 标记
      Returns:
      this builder - 此构建器
    • traceId

      public StructuredLog.Builder traceId(String traceId)
      Sets the trace ID. 设置追踪 ID。
      Parameters:
      traceId - the trace ID - 追踪 ID
      Returns:
      this builder - 此构建器
    • spanId

      public StructuredLog.Builder spanId(String 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

      public void log(Logger logger)
      Logs to the specified logger. 记录到指定的日志记录器。
      Parameters:
      logger - the logger - 日志记录器