File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,20 @@ type Levels struct {
1010 ctx log.Context
1111 levelKey string
1212
13+ // We have a choice between storing level values in string fields or
14+ // making a separate context for each level. When using string fields the
15+ // Log method must combine the base context, the level data, and the
16+ // logged keyvals; but the With method only requires updating one context.
17+ // If we instead keep a separate context for each level the Log method
18+ // must only append the new keyvals; but the With method would have to
19+ // update all five contexts.
20+
21+ // Roughly speaking, storing multiple contexts breaks even if the ratio of
22+ // Log/With calls is more than the number of levels. We have chosen to
23+ // make the With method cheap and the Log method a bit more costly because
24+ // we do not expect most applications to Log more than five times for each
25+ // call to With.
26+
1327 debugValue string
1428 infoValue string
1529 warnValue string
You can’t perform that action at this time.
0 commit comments