Interface LogRecordBuilder
-
- All Known Subinterfaces:
ExtendedLogRecordBuilder
- All Known Implementing Classes:
DefaultLogger.NoopLogRecordBuilder
,ExtendedDefaultLogger.NoopLogRecordBuilder
,SdkLogRecordBuilder
public interface LogRecordBuilder
Used 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 void
emit()
Emit the log record.default LogRecordBuilder
setAllAttributes(Attributes attributes)
Sets attributes.<T> LogRecordBuilder
setAttribute(AttributeKey<T> key, T value)
Sets an attribute.default LogRecordBuilder
setBody(Value<?> body)
Set the bodyValue
.LogRecordBuilder
setBody(java.lang.String body)
Set the body string.LogRecordBuilder
setContext(Context context)
Set the context.LogRecordBuilder
setObservedTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)
Set the epochobservedTimestamp
, using the timestamp and unit.LogRecordBuilder
setObservedTimestamp(java.time.Instant instant)
Set theobservedTimestamp
, using the instant.LogRecordBuilder
setSeverity(Severity severity)
Set the severity.LogRecordBuilder
setSeverityText(java.lang.String severityText)
Set the severity text.LogRecordBuilder
setTimestamp(long timestamp, java.util.concurrent.TimeUnit unit)
Set the epochtimestamp
, using the timestamp and unit.LogRecordBuilder
setTimestamp(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
timestamp
is 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
timestamp
is 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
observedTimestamp
is the time at which the log record was observed. If unset, it will be set to thetimestamp
.observedTimestamp
may be different fromtimestamp
if 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
observedTimestamp
is the time at which the log record was observed. If unset, it will be set to thetimestamp
.observedTimestamp
may be different fromtimestamp
if 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 theLogRecordBuilder
previously 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.
-
-