This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
57 lines (49 loc) · 1.97 KB
/
logger.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
51
52
53
54
55
56
57
package twelf
var (
// DefaultLogger is a logger that only logs non-debug messages.
DefaultLogger Logger = &StandardLogger{CaptureDebug: false}
// DebugLogger is a logger that logs both debug and non-debug messages.
DebugLogger Logger = &StandardLogger{CaptureDebug: true}
// SilentLogger is a logger that does not log any messages.
SilentLogger Logger = DiscardLogger{}
)
// Logger is an interface for writing log messages.
type Logger interface {
// Log writes an application log message formatted according to a format
// specifier.
//
// It should be ussed for messages that are intended for people responsible for
// operating the application, such as the end-user or operations staff.
//
// fmt is the format specifier, as per fmt.Printf(), etc.
Log(fmt string, v ...interface{})
// LogString writes a pre-formatted application log message.
//
// It should be ussed for messages that are intended for people responsible for
// operating the application, such as the end-user or operations staff.
LogString(s string)
// Debug writes a debug log message formatted according to a format
// specifier.
//
// If IsDebug() returns false, no logging is performed.
//
// It should be used for messages that are intended for the software developers
// that maintain the application.
//
// fmt is the format specifier, as per fmt.Printf(), etc.
Debug(fmt string, v ...interface{})
// DebugString writes a pre-formatted debug log message.
//
// If IsDebug() returns false, no logging is performed.
//
// It should be used for messages that are intended for the software developers
// that maintain the application.
DebugString(s string)
// IsDebug returns true if this logger will perform debug logging.
//
// Generally the application should just call Debug() or DebugString() without
// calling IsDebug(), however it can be used to check if debug logging is
// necessary before executing expensive code that is only used to obtain debug
// information.
IsDebug() bool
}