LoggingScope

public abstract class LoggingScope

An opaque scope marker which can be attached to log sites to provide "per scope" behaviour for stateful logging operations (e.g. rate limiting).

Scopes are provided via the Provider interface and found by looking for the current ScopedLoggingContexts.

Stateful fluent logging APIs which need to look up per log site information (e.g. rate limit state) should do so via a LogSiteMap using the LogSiteKey passed into the postProcess method. If scopes are present in the log site then the log site key provided to the postProcess() method will already be specialized to take account of any scopes present.

Note that scopes have no effect when applied to stateless log statements (e.g. log statements without rate limiting) since the log site key for that log statement will not be used in any maps.

Constructors

Link copied to clipboard
protected void LoggingScope(String label)
Creates a basic scope with the specified label.

Functions

Link copied to clipboard
public static LoggingScope create(String label)
Creates a scope which automatically removes any associated keys from LogSiteMaps when it's garbage collected.
Link copied to clipboard
protected abstract void onClose(Runnable removalHook)
Registers "hooks" which should be called when this scope is "closed".
Link copied to clipboard
protected abstract LogSiteKey specialize(LogSiteKey key)
Returns a specialization of the given key which accounts for this scope instance.
Link copied to clipboard
public final String toString()