Metadata

public abstract class Metadata

A sequence of metadata key/value pairs which can be associated to a log statement, either directly via methods in the fluent API, of as part of a scoped logging context.

Metadata keys can be “single valued” or “repeating” based on MetadataKey.canRepeat(), but it is permitted for a Metadata implementation to retain multiple single valued keys, and in that situation the key at the largest index is the one that should be used.

Multiple Metadata instances can be merged, in order, to provide a final sequence for a log statement. When Metadata instance are merged, the result is just the concatenation of the sequence of key/value pairs, and this is what results in the potential for multiple single valued keys to exist.

If the value of a single valued key is required, the findValue method should be used to look it up. For all other metadata processing, a MetadataProcessor should be created to ensure that scope and log site metadata can be merged correctly.

See also

<a href="https://github.com/google/flogger/blob/cb9e836a897d36a78309ee8badf5cad4e6a2d3d8/api/src/main/java/com/google/common/flogger/backend/Metadata.java">

Original Java code of Google Flogger

Inheritors

Constructors

Link copied to clipboard
public void Metadata()

Functions

Link copied to clipboard
public static Metadata empty()
Returns an immutable Metadata that has no items.
Link copied to clipboard
@Nullable()
public abstract @Nullable() T findValue<T>(FloggerMetadataKey<T> key)
Returns the first value for the given single valued metadata key, or null if it does not exist.
Link copied to clipboard
public abstract FloggerMetadataKey<? extends Object> getKey(int n)
Returns the key for the Nth piece of metadata.
Link copied to clipboard
public abstract Object getValue(int n)
Returns the non-null value for the Nth piece of metadata.
Link copied to clipboard
public abstract int size()
Returns the number of key/value pairs for this instance.