forked from vanadium-archive/go.v23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
126 lines (101 loc) · 4.68 KB
/
model.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package loging defines an interface for logging modeled on Google's glog.
package logging
type InfoLog interface {
// Info logs to the INFO log.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Info(args ...interface{})
// Infoln logs to the INFO log.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Infof(format string, args ...interface{})
// InfoDepth acts as Info but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Info.
InfoDepth(depth int, args ...interface{})
// InfoStack logs the current goroutine's stack if the all parameter
// is false, or the stacks of all goroutines if it's true.
InfoStack(all bool)
}
type ErrorLog interface {
// Error logs to the ERROR and INFO logs.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Error(args ...interface{})
// ErrorDepth acts as Error but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Error.
ErrorDepth(depth int, args ...interface{})
// Errorf logs to the ERROR and INFO logs.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Errorf(format string, args ...interface{})
}
type FatalLog interface {
// Fatal logs to the FATAL, ERROR and INFO logs,
// including a stack trace of all running goroutines, then calls os.Exit(255).
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Fatal(args ...interface{})
// FatalDepth acts as Fatal but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Fatal.
FatalDepth(depth int, args ...interface{})
// Fatalf logs to the FATAL, ERROR and INFO logs,
// including a stack trace of all running goroutines, then calls os.Exit(255).
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Fatalf(format string, args ...interface{})
}
type PanicLog interface {
// Panic is equivalent to Error() followed by a call to panic().
Panic(args ...interface{})
// PanicDepth acts as Panic but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Panic.
PanicDepth(depth int, args ...interface{})
// Panicf is equivalent to Errorf() followed by a call to panic().
Panicf(format string, args ...interface{})
}
type Verbosity interface {
// V returns true if the configured logging level is greater than or equal to its parameter
V(level int) bool
// VDepth acts as V but uses depth to determine which call frame to test against.
VDepth(depth int, level int) bool
// VI is like V, except that it returns an anonymous interface that with the
// same method set as InfoLog that will either log (if level >= the configured level)
// or discard its parameters. This allows for logger.VI(2).Info style usage. An
// anonymous interface is used to allow for implementations that don't need to
// depend on this package.
VI(level int) interface {
// Info logs to the INFO log.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Info(args ...interface{})
// Infoln logs to the INFO log.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Infof(format string, args ...interface{})
// InfoDepth acts as Info but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Info.
InfoDepth(depth int, args ...interface{})
// InfoStack logs the current goroutine's stack if the all parameter
// is false, or the stacks of all goroutines if it's true.
InfoStack(all bool)
}
// VIDepth acts as VI but uses depth to determine which call frame to test against.
VIDepth(depth int, level int) interface {
// Info logs to the INFO log.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Info(args ...interface{})
// Infoln logs to the INFO log.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Infof(format string, args ...interface{})
// InfoDepth acts as Info but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Info.
InfoDepth(depth int, args ...interface{})
// InfoStack logs the current goroutine's stack if the all parameter
// is false, or the stacks of all goroutines if it's true.
InfoStack(all bool)
}
}
type Logger interface {
InfoLog
ErrorLog
FatalLog
PanicLog
Verbosity
// Flush flushes all pending log I/O.
FlushLog()
}