Interface LogRecordBuilder
-
- All Known Subinterfaces:
ExtendedLogRecordBuilder
- All Known Implementing Classes:
DefaultLogger.NoopLogRecordBuilder,ExtendedDefaultLogger.NoopLogRecordBuilder,SdkLogRecordBuilder
public interface LogRecordBuilderUsed to construct and emit log records from aLogger.Obtain a
Logger.logRecordBuilder(), add properties using the setters, and emit the log record by callingemit().- Since:
- 1.27.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidemit()Emit the log record.default LogRecordBuildersetAllAttributes(Attributes attributes)Sets attributes.<T> LogRecordBuildersetAttribute(AttributeKey<T> key, T value)Sets an attribute.default LogRecordBuildersetBody(Value<?> body)Set the bodyValue.LogRecordBuildersetBody(java.lang.String body)Set the body string.LogRecordBuildersetContext(Context context)Set the context.LogRecordBuildersetObservedTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)Set the epochobservedTimestamp, using the timestamp and unit.LogRecordBuildersetObservedTimestamp(java.time.Instant instant)Set theobservedTimestamp, using the instant.LogRecordBuildersetSeverity(Severity severity)Set the severity.LogRecordBuildersetSeverityText(java.lang.String severityText)Set the severity text.LogRecordBuildersetTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)Set the epochtimestamp, using the timestamp and unit.LogRecordBuildersetTimestamp(java.time.Instant instant)Set the epochtimestamp, using the instant.
-
-
-
Method Detail
-
setTimestamp
LogRecordBuilder setTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)
Set the epochtimestamp, using the timestamp and unit.The
timestampis the time at which the log record occurred. If unset, it will be set to the current time whenemit()is called.
-
setTimestamp
LogRecordBuilder setTimestamp(java.time.Instant instant)
Set the epochtimestamp, using the instant.The
timestampis the time at which the log record occurred. If unset, it will be set to the current time whenemit()is called.
-
setObservedTimestamp
LogRecordBuilder setObservedTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)
Set the epochobservedTimestamp, using the timestamp and unit.The
observedTimestampis the time at which the log record was observed. If unset, it will be set to thetimestamp.observedTimestampmay be different fromtimestampif logs are being processed asynchronously (e.g. from a file or on a different thread).
-
setObservedTimestamp
LogRecordBuilder setObservedTimestamp(java.time.Instant instant)
Set theobservedTimestamp, using the instant.The
observedTimestampis the time at which the log record was observed. If unset, it will be set to thetimestamp.observedTimestampmay be different fromtimestampif logs are being processed asynchronously (e.g. from a file or on a different thread).
-
setContext
LogRecordBuilder setContext(Context context)
Set the context.
-
setSeverity
LogRecordBuilder setSeverity(Severity severity)
Set the severity.
-
setSeverityText
LogRecordBuilder setSeverityText(java.lang.String severityText)
Set the severity text.
-
setBody
LogRecordBuilder setBody(java.lang.String body)
Set the body string.Shorthand for calling
setBody(Value)withValue.of(String).
-
setBody
default LogRecordBuilder setBody(Value<?> body)
Set the bodyValue.- Since:
- 1.42.0
-
setAllAttributes
default LogRecordBuilder setAllAttributes(Attributes attributes)
Sets attributes. If theLogRecordBuilderpreviously contained a mapping for any of the keys, the old values are replaced by the specified values.
-
setAttribute
<T> LogRecordBuilder setAttribute(AttributeKey<T> key, T value)
Sets an attribute.
-
emit
void emit()
Emit the log record.
-
-