Description
Is your feature request related to a problem? Please describe.
The LoggingEnhancer
interface enables an implementer to add extra content to a LogEntry
. However, the LoggingEnhancer
is not itself given any context about the underlying LogRecord
, so any added content must essentially be static and unrelated to the specific log record.
Some logging systems, like flogger, subclass java.util.logging.LogRecord
(e.g., flogger makes a com.google.common.flogger.backend.system.AbstractLogRecord
) and add extra information (e.g., in the case of flogger, the AbstractLogRecord
has getLogData().getLogSite()
which offers a much more efficient and less hassle-free mechanism of retrieving log site information than com.google.cloud.logging.SourceLocation.fromCurrentContext
).
Describe the solution you'd like
Can we add a LogRecord
parameter to LoggingEnhancer.enhanceLogEntry
? This would be a breaking change; if it's too late for such a change, maybe we need a LoggingEnhancerWithRecord
or LoggingEnhancer2
.
Then as a follow-on, some library can supply the glue for flogger and this library: a stock LoggingEnhancer
to supply the LogSite
.
Describe alternatives you've considered
We currently have a logging handler which downcasts the LogRecord
, but it has its own java.util.logging.LogHandler
implementation and thus doesn't use LoggingHandler
or the java-logging
library. I'm filing this feature request in hopes of replacing that internal implementation.
Additional context
Contact me for the internal example of downcasting LogRecord
. :)