WithContext returns a Logger that has information about the current user in its details. e.g. log := util.WithContext(ctx) log.Errorf("Could not chunk chunks: %v", err)
(ctx context.Context, l kitlog.Logger)
| 30 | // log := util.WithContext(ctx) |
| 31 | // log.Errorf("Could not chunk chunks: %v", err) |
| 32 | func WithContext(ctx context.Context, l kitlog.Logger) kitlog.Logger { |
| 33 | userID, err := tenant.TenantID(ctx) |
| 34 | if err == nil { |
| 35 | l = WithUserID(userID, l) |
| 36 | } |
| 37 | |
| 38 | traceID, ok := tracing.ExtractSampledTraceID(ctx) |
| 39 | if !ok { |
| 40 | return l |
| 41 | } |
| 42 | |
| 43 | return WithTraceID(traceID, l) |
| 44 | } |
| 45 | |
| 46 | // WithSourceIPs returns a Logger that has information about the source IPs in |
| 47 | // its details. |
no test coverage detected