podman

Форк
0
117 строк · 2.9 Кб
1
/*
2
 *
3
 * Copyright 2020 gRPC authors.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18

19
package grpclog
20

21
import (
22
	"fmt"
23

24
	"google.golang.org/grpc/internal/grpclog"
25
)
26

27
// componentData records the settings for a component.
28
type componentData struct {
29
	name string
30
}
31

32
var cache = map[string]*componentData{}
33

34
func (c *componentData) InfoDepth(depth int, args ...any) {
35
	args = append([]any{"[" + string(c.name) + "]"}, args...)
36
	grpclog.InfoDepth(depth+1, args...)
37
}
38

39
func (c *componentData) WarningDepth(depth int, args ...any) {
40
	args = append([]any{"[" + string(c.name) + "]"}, args...)
41
	grpclog.WarningDepth(depth+1, args...)
42
}
43

44
func (c *componentData) ErrorDepth(depth int, args ...any) {
45
	args = append([]any{"[" + string(c.name) + "]"}, args...)
46
	grpclog.ErrorDepth(depth+1, args...)
47
}
48

49
func (c *componentData) FatalDepth(depth int, args ...any) {
50
	args = append([]any{"[" + string(c.name) + "]"}, args...)
51
	grpclog.FatalDepth(depth+1, args...)
52
}
53

54
func (c *componentData) Info(args ...any) {
55
	c.InfoDepth(1, args...)
56
}
57

58
func (c *componentData) Warning(args ...any) {
59
	c.WarningDepth(1, args...)
60
}
61

62
func (c *componentData) Error(args ...any) {
63
	c.ErrorDepth(1, args...)
64
}
65

66
func (c *componentData) Fatal(args ...any) {
67
	c.FatalDepth(1, args...)
68
}
69

70
func (c *componentData) Infof(format string, args ...any) {
71
	c.InfoDepth(1, fmt.Sprintf(format, args...))
72
}
73

74
func (c *componentData) Warningf(format string, args ...any) {
75
	c.WarningDepth(1, fmt.Sprintf(format, args...))
76
}
77

78
func (c *componentData) Errorf(format string, args ...any) {
79
	c.ErrorDepth(1, fmt.Sprintf(format, args...))
80
}
81

82
func (c *componentData) Fatalf(format string, args ...any) {
83
	c.FatalDepth(1, fmt.Sprintf(format, args...))
84
}
85

86
func (c *componentData) Infoln(args ...any) {
87
	c.InfoDepth(1, args...)
88
}
89

90
func (c *componentData) Warningln(args ...any) {
91
	c.WarningDepth(1, args...)
92
}
93

94
func (c *componentData) Errorln(args ...any) {
95
	c.ErrorDepth(1, args...)
96
}
97

98
func (c *componentData) Fatalln(args ...any) {
99
	c.FatalDepth(1, args...)
100
}
101

102
func (c *componentData) V(l int) bool {
103
	return V(l)
104
}
105

106
// Component creates a new component and returns it for logging. If a component
107
// with the name already exists, nothing will be created and it will be
108
// returned. SetLoggerV2 will panic if it is called with a logger created by
109
// Component.
110
func Component(componentName string) DepthLoggerV2 {
111
	if cData, ok := cache[componentName]; ok {
112
		return cData
113
	}
114
	c := &componentData{componentName}
115
	cache[componentName] = c
116
	return c
117
}
118

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.