upvote
> Which then gets discarded because that was a Log.verbose and your minimum log level in production is WARN.

This isn't true for the LogEvent or equivalent object, which only gets created after the log level is tested to be applicable by the logger implementation.

For call-site object allocation, you can wrap the logging call into an if statement that checks for the corresponding log level. The lambda allocation isn't constant if it captures anything from the surrounding scope, which will generally be the case for logging calls. (Unless by "constant" you mean that it's a single allocation per execution.)

reply