Debian Codegraph @

message/log.go

raw symbols SCIP
1 // Copyright 2016 VMware, Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package message
16
17 import "log"
18
19 var DefaultLogger Logger
20
21 type Logger interface {
22 Errorf(format string, args ...interface{})
23 Debugf(format string, args ...interface{})
24 Infof(format string, args ...interface{})
25 }
26
27 func init() {
28 DefaultLogger = &logger{}
29 }
30
31 type logger struct {
32 DebugLevel bool
33 }
34
35 func (l *logger) Errorf(format string, args ...interface{}) {
36 log.Printf(format, args...)
37 }
38
39 func (l *logger) Debugf(format string, args ...interface{}) {
40 if !l.DebugLevel {
41 return
42 }
43
44 log.Printf(format, args...)
45 }
46
47 func (l *logger) Infof(format string, args ...interface{}) {
48 log.Printf(format, args...)
49 }
50
51 func Errorf(format string, args ...interface{}) {
52 DefaultLogger.Errorf(format, args...)
53 }
54
55 func Debugf(format string, args ...interface{}) {
56 DefaultLogger.Debugf(format, args...)
57 }
58
59 func Infof(format string, args ...interface{}) {
60 DefaultLogger.Infof(format, args...)
61 }