Debian Codegraph @

logger.go

raw symbols SCIP
1 // Copyright The Prometheus Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package probing
15
16 import "log"
17
18 type Logger interface {
19 Fatalf(format string, v ...any)
20 Errorf(format string, v ...any)
21 Warnf(format string, v ...any)
22 Infof(format string, v ...any)
23 Debugf(format string, v ...any)
24 }
25
26 type StdLogger struct {
27 Logger *log.Logger
28 }
29
30 func (l StdLogger) Fatalf(format string, v ...any) {
31 l.Logger.Printf("FATAL: "+format, v...)
32 }
33
34 func (l StdLogger) Errorf(format string, v ...any) {
35 l.Logger.Printf("ERROR: "+format, v...)
36 }
37
38 func (l StdLogger) Warnf(format string, v ...any) {
39 l.Logger.Printf("WARN: "+format, v...)
40 }
41
42 func (l StdLogger) Infof(format string, v ...any) {
43 l.Logger.Printf("INFO: "+format, v...)
44 }
45
46 func (l StdLogger) Debugf(format string, v ...any) {
47 l.Logger.Printf("DEBUG: "+format, v...)
48 }
49
50 type NoopLogger struct {
51 }
52
53 func (l NoopLogger) Fatalf(_ string, _ ...any) {
54 }
55
56 func (l NoopLogger) Errorf(_ string, _ ...any) {
57 }
58
59 func (l NoopLogger) Warnf(_ string, _ ...any) {
60 }
61
62 func (l NoopLogger) Infof(_ string, _ ...any) {
63 }
64
65 func (l NoopLogger) Debugf(_ string, _ ...any) {
66 }