google / flogger

A Fluent Logging API for Java
Apache License 2.0
1.45k stars 123 forks source link

Use Tags.empty() as no-op argument. Reject multiple calls to withLogLevelMap. #359

Closed copybara-service[bot] closed 11 months ago

copybara-service[bot] commented 11 months ago

Use Tags.empty() as no-op argument. Reject multiple calls to withLogLevelMap.

Accepting no-op arguments allows ScopedLoggingContext to conditionally add values. A complete no-op, however, allows for syntactic misuse of the builder, calling the same method multiple times as long as all but the last provide null values.

LogLevelMap requires special care, as once a LogLevelMap is set (even if logically empty), every single log statement needs to evaluate the map.

RELNOTES=Enforce calling ScopedLoggingContext.Builder methods at most once, even with no-op params.