ContextDataProvider

public abstract class ContextDataProvider

An API for injecting scoped metadata for log statements (either globally or on a per-request basis). Thiis class is not a public API and should never need to be invoked directly by application code.

Note that since this class (and any installed implementation sub-class) is loaded when the logging platform is loaded, care must be taken to avoid cyclic references during static initialisation. This means that no static fields or static initialization can reference fluent loggers or the logging platform (either directly or indirectly).

This is a service type

This type is considered a service type and implemenations may be loaded from the classpath via java.util.ServiceLoader provided the proper service metadata is included in the jar file containing the implementation. When creating an implementation of this class, you can provide serivce metadata (and thereby allow users to get your implementation just by including your jar file) by either manually including a META-INF/services/io.spine.logging.flogger.context.ContextDataProvider file containing the name of your implementation class or by annotating your implementation class using @AutoService(ContextDataProvider.class). See the documentation of both java.util.ServiceLoader and DefaultPlatform for more information.

See also

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

Original Java code of Google Flogger

Constructors

Link copied to clipboard
public void ContextDataProvider()

Functions

Link copied to clipboard
Returns the context API with which users can create and modify the state of logging contexts within an application.
Link copied to clipboard
Returns the singleton instance of the context data provider for use by logging platform implementations.
Link copied to clipboard
Returns metadata to be applied to a log statement.
Link copied to clipboard
Returns the singleton no-op context data provider, which can be used by platform implementations which don't support ScopedLoggingContext for some reason.
Link copied to clipboard
@Nullable()
public @Nullable() LoggingScope getScope(ScopeType type)
Returns the scope instance of the specified type for this context, or null if no such scope was bound to this context.
Link copied to clipboard
public Tags getTags()
Returns a set of tags to be added to a log statement.
Link copied to clipboard
public boolean shouldForceLogging(String loggerName, Level level, boolean isEnabledByLevel)
Returns whether the given logger should have logging forced at the specified level.