Debian Codegraph @

zapr_noslog_test.go

raw symbols SCIP
1 //go:build !go1.21 && !go1.21
2 // +build !go1.21,!go1.21
3
4 /*
5 Copyright 2023 The logr Authors.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 */
19
20 package zapr_test
21
22 import (
23 "fmt"
24
25 "github.com/go-logr/logr"
26 "go.uber.org/zap"
27 "go.uber.org/zap/zapcore"
28 )
29
30 // These implementations only exist to allow the tests to compile. Test cases
31 // that depend on slog support get skipped at runtime.
32
33 func hasSlog() bool {
34 return false
35 }
36
37 func slogInt(key string, value int) zap.Field {
38 return zap.Int(key, value)
39 }
40
41 func slogString(key string, value string) zap.Field {
42 return zap.String(key, value)
43 }
44
45 func slogGroup(key string, values ...zap.Field) zap.Field {
46 return zap.Object(key, zapcore.ObjectMarshalerFunc(func(encoder zapcore.ObjectEncoder) error {
47 for _, value := range values {
48 value.AddTo(encoder)
49 }
50 return nil
51 }))
52 }
53
54 func slogValue(value interface{}) string {
55 return fmt.Sprintf("%v", value)
56 }
57
58 func slogValuer(value interface{}) interface{} {
59 return value
60 }
61
62 func logWithSlog(_ logr.Logger, _ string, _, _ []interface{}) {
63 }