Class LogContext.Key
- java.lang.Object
-
- com.google.common.flogger.LogContext.Key
-
- Enclosing class:
- LogContext<LOGGER extends AbstractLogger<API>,API extends LoggingApi<API>>
public static final class LogContext.Key extends Object
The predefined metadata keys used by the default logging API. Backend implementations can use these to identify metadata added by the core logging API.
-
-
Field Summary
Fields Modifier and Type Field Description static MetadataKey<StackSize>CONTEXT_STACK_SIZEKey associated with the metadata for specifying additional stack information with a log statement.static MetadataKey<com.google.common.flogger.DurationRateLimiter.RateLimitPeriod>LOG_AT_MOST_EVERYThe key associated with a rate limiting period for "at most once every N" rate limiting.static MetadataKey<Throwable>LOG_CAUSEThe key associated with aThrowablecause to be associated with the log message.static MetadataKey<Integer>LOG_EVERY_NThe key associated with a rate limiting counter for "1-in-N" rate limiting.static MetadataKey<Integer>LOG_SAMPLE_EVERY_NThe key associated with a rate limiting counter for "1-in-N" randomly sampled rate limiting.static MetadataKey<Object>LOG_SITE_GROUPING_KEYThe key associated with a sequence of log site "grouping keys".static MetadataKey<Integer>SKIPPED_LOG_COUNTThe key associated with a count of rate limited logs.static MetadataKey<Tags>TAGSThe key associated with any injectedTags.static MetadataKey<Boolean>WAS_FORCEDThe key associated with aBooleanvalue used to specify that the log statement must be emitted.
-
-
-
Field Detail
-
LOG_CAUSE
public static final MetadataKey<Throwable> LOG_CAUSE
The key associated with aThrowablecause to be associated with the log message. This value is set byLoggingApi.withCause(Throwable).
-
LOG_EVERY_N
public static final MetadataKey<Integer> LOG_EVERY_N
The key associated with a rate limiting counter for "1-in-N" rate limiting. The value is set byLoggingApi.every(int).
-
LOG_SAMPLE_EVERY_N
public static final MetadataKey<Integer> LOG_SAMPLE_EVERY_N
The key associated with a rate limiting counter for "1-in-N" randomly sampled rate limiting. The value is set byLoggingApi.onAverageEvery(int).
-
LOG_AT_MOST_EVERY
public static final MetadataKey<com.google.common.flogger.DurationRateLimiter.RateLimitPeriod> LOG_AT_MOST_EVERY
The key associated with a rate limiting period for "at most once every N" rate limiting. The value is set byLoggingApi.atMostEvery(int, TimeUnit).
-
SKIPPED_LOG_COUNT
public static final MetadataKey<Integer> SKIPPED_LOG_COUNT
The key associated with a count of rate limited logs. This is only public so backends can reference the key to control formatting.
-
LOG_SITE_GROUPING_KEY
public static final MetadataKey<Object> LOG_SITE_GROUPING_KEY
The key associated with a sequence of log site "grouping keys". These serve to specialize the log site key to group the behaviour of stateful operations like rate limiting. This is used by theper()methods and is only public so backends can reference the key to control formatting.
-
WAS_FORCED
public static final MetadataKey<Boolean> WAS_FORCED
The key associated with aBooleanvalue used to specify that the log statement must be emitted.Forcing a log statement ensures that the
LoggerBackendis passed theLogDatafor this log statement regardless of the backend's log level or any other filtering or rate limiting which might normally occur. If a log statement is forced, this key will be set immediately on creation of the logging context and will be visible to both fluent methods and post-processing.Filtering and rate-limiting methods must check for this value and should treat forced log statements as not having had any filtering or rate limiting applied. For example, if the following log statement was forced:
it should behave as if the rate-limiting methods were never called, such as:logger.atInfo().withCause(e).atMostEvery(1, MINUTES).log("Message...");
As well as no longer including any rate-limiting metadata for the forced log statement, this also has the effect of never interfering with the rate-limiting of this log statement for other callers.logger.atInfo().withCause(e).log("Message...");The decision of whether to force a log statement is expected to be made based upon debug values provded by the logger which come from a scope greater than the log statement itself. Thus it makes no sense to provide a public method to set this value programmatically for a log statement.
-
TAGS
public static final MetadataKey<Tags> TAGS
The key associated with any injectedTags.If tags are injected, they are added after post-processing if the log site is enabled. Thus they are not available to the
postProcess()method itself. The rationale is that a log statement's behavior should only be affected by code at the log site (other than "forcing" log statements, which is slightly a special case).Tags can be added at the log site, although this should rarely be necessary and using normal log message arguments is always the preferred way to indicate unstrctured log data. Users should never build new
Tagsinstances just to pass them into a log statement.
-
CONTEXT_STACK_SIZE
public static final MetadataKey<StackSize> CONTEXT_STACK_SIZE
Key associated with the metadata for specifying additional stack information with a log statement.
-
-