new Context
Creates a new context builder to which additional logging metadata can be attached before being installed or used to wrap some existing code.
ScopedLoggingContext ctx = ScopedLoggingContext.getInstance();
Foo result = ctx.newContext().withTags(Tags.of("my_tag", someValue)).call(MyClass::doFoo);
Implementations of this API must return a subclass of Builder which can install all necessary metadata into a new context from the builder's current state.
Note for users: if you don't need an instance of ScopedLoggingContext for some reason such as testability (injecting it, for example), consider using the static methods in ScopedLoggingContexts instead to avoid the need to call getInstance:
Foo result = ScopedLoggingContexts.newContext()
.withTags(Tags.of("my_tag", someValue))
.call(MyClass::doFoo);
Creates a new context builder to which additional logging metadata can be attached before being installed or used to wrap some existing code.
This method is the same as newContext except it additionally binds a new instance to the newly created context. This allows log statements to control stateful logging operations (e.g. rate limiting) using per(ScopeType) method.
Note for users: if you don't need an instance of ScopedLoggingContext for some reason such as testability (injecting it, for example), consider using the static methods in ScopedLoggingContexts instead to avoid the need to call getInstance.