-
-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Description
Context
SLF4J/Logback ILoggingEvent
(source) has two important fields / getter methods:
message
- contains the message template (e.g."Hello {}!"
)formattedMessage
- contains the final formatted/merged log message (e.g."Hello world!"
)
This distinction is useful -- for example, we use this to aggregate log messages.
Issue
KLogger
relies on Kotlin string interpolation and as a result, the message
field contains the same formatted message as formattedMessage
, breaking the possibilities for aggregation.
Proposal
Introduce a new field in KLoggingEventBuilder
that could contain the log message template (e.g. "Hello $variable!"
):
- in case this field is filled, it is passed as-is to SLF4J
LoggingEvent.message
field and the formatted log message is passed toLoggingEvent.formattedMessage
(see also Allow to pass in a "formatted message" via SLF4J LoggingEvent (in addition to "message" field) qos-ch/slf4j#437). - in case this field is not filled, the current behaviour is followed (using the formatted message for
LoggingEvent.message
and leavingLoggingEvent.formattedMessage
empty).
This will make it easier for me to implement something on top of KLogger
to fill that field properly (I'm thinking of implementing a Kotlin compiler plugin).
Metadata
Metadata
Assignees
Labels
No labels