-
Notifications
You must be signed in to change notification settings - Fork 0
/
emptylogger.go
50 lines (40 loc) · 1.18 KB
/
emptylogger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// nul.go - Nul Logger instance
//
// Copyright 2009 The Go Authors. All rights reserved.
//
// Changes Copyright 2012, Sudhi Herle <sudhi -at- herle.net>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package logger
type emptyLogger struct {
prio Priority
prefix string
}
var _ Logger = &emptyLogger{}
func newNullLogger(pref string, prio Priority) *emptyLogger {
return &emptyLogger{
prio: prio,
prefix: pref,
}
}
func (e *emptyLogger) New(pref string, prio Priority) Logger {
return newNullLogger(pref, prio)
}
func (e *emptyLogger) Close() error {
return nil
}
func (e *emptyLogger) Loggable(p Priority) bool {
return e.prio > LOG_NONE && p >= e.prio
}
func (e *emptyLogger) Fatal(s string, v ...interface{}) {}
func (e *emptyLogger) Crit(s string, v ...interface{}) {}
func (e *emptyLogger) Error(s string, v ...interface{}) {}
func (e *emptyLogger) Warn(s string, v ...interface{}) {}
func (e *emptyLogger) Info(s string, v ...interface{}) {}
func (e *emptyLogger) Debug(s string, v ...interface{}) {}
func (e *emptyLogger) Prio() Priority {
return e.prio
}
func (e *emptyLogger) Prefix() string {
return e.prefix
}