[Logging] Add callback interface to logging methods for message serialization #129110
Labels
enhancement
New value added to drive a business result
Feature:Logging
Team:Core
Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
For the
Logger
interfaces it would be nice if we could use a callback for the message creation so when we need to serialized data, it only happens if the logging level is enabled.Imagine you're setting up trace logging for request/response for queries against Elasticsearch but you only want to serialized the data when
trace
logging is enabled (scoped to a very specific part of the application). If the response is large enough, the following code will cause a delay because regardless of the current logging level, it always runsJSON.stringify
.But if if the
trace
method acceptedstring | () => string
formessage
then we could do this:CC: @dgieselaar
The text was updated successfully, but these errors were encountered: