Builder

public abstract class Builder

A fluent builder API for creating and installing new context scopes. This API should be used whenever the metadata to be added to a scope is known at the time the scope is created.

This class is intended to be used only as part of a fluent statement, and retaining a reference to a builder instance for any length of time is not recommended.

Constructors

Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard
protected Tags tags

Functions

Link copied to clipboard
@CanIgnoreReturnValue()
public final R call<R>(Callable<R> c)
Calls a Callable directly within a new context installed from this builder.
Link copied to clipboard
@CanIgnoreReturnValue()
public final R callUnchecked<R>(Callable<R> c)
Calls a Callable directly within a new context installed from this builder, wrapping any checked exceptions with a RuntimeException.
Link copied to clipboard
@Nullable()
protected final @Nullable() LogLevelMap getLogLevelMap()
Returns the configured log level map, or null.
Link copied to clipboard
@Nullable()
protected final @Nullable() ContextMetadata getMetadata()
Returns the configured context metadata, or null.
Link copied to clipboard
@Nullable()
protected final @Nullable() Tags getTags()
Returns the configured tags, or null.
Link copied to clipboard
@MustBeClosed()
public abstract ScopedLoggingContext.LoggingContextCloseable install()
Installs a new context based on the state of the builder.
Link copied to clipboard
public final void run(Runnable r)
Runs a runnable directly within a new context installed from this builder.
Link copied to clipboard
@CanIgnoreReturnValue()
public final ScopedLoggingContext.Builder withLogLevelMap(LogLevelMap logLevelMap)
Sets the log level map to be used with the context being built.
Link copied to clipboard
@CanIgnoreReturnValue()
public final ScopedLoggingContext.Builder withMetadata<T>(FloggerMetadataKey<T> key, T value)
Adds a single metadata key/value pair to the context.
Link copied to clipboard
@CanIgnoreReturnValue()
public final ScopedLoggingContext.Builder withTags(Tags tags)
Sets the tags to be used with the context.
Link copied to clipboard
public final Runnable wrap(Runnable r)
Wraps a runnable so it will execute within a new context based on the state of the builder.
public final Callable<R> wrap<R>(Callable<R> c)
Wraps a callable so it will execute within a new context based on the state of the builder.