/
interface.go
60 lines (52 loc) · 1.61 KB
/
interface.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
package logger
import (
"io"
"github.com/Reshusk23/dme-go-logger/proto"
)
// Logger defines the behavior of a data logger component
type Logger interface {
Trace(message string, args ...interface{})
Debug(message string, args ...interface{})
Info(message string, args ...interface{})
Warn(message string, args ...interface{})
Error(message string, args ...interface{})
LogIfError(err error, args ...interface{})
Log(line *LogLine)
SetLevel(logLevel LogLevel)
GetLevel() LogLevel
IsInterfaceNil() bool
}
// LogLineHandler defines the get methods for a log line struct used by the formatter interface
type LogLineHandler interface {
GetLoggerName() string
GetCorrelation() proto.LogCorrelationMessage
GetMessage() string
GetLogLevel() int32
GetArgs() []string
GetTimestamp() int64
IsInterfaceNil() bool
}
// Formatter describes what a log formatter should be able to do
type Formatter interface {
Output(line LogLineHandler) []byte
IsInterfaceNil() bool
}
// LogOutputHandler defines the properties of a subject-observer component
// able to output log lines
type LogOutputHandler interface {
Output(line *LogLine)
AddObserver(w io.Writer, format Formatter) error
RemoveObserver(w io.Writer) error
ClearObservers()
IsInterfaceNil() bool
}
// Marshalizer defines the 2 basic operations: serialize (marshal) and deserialize (unmarshal)
type Marshalizer interface {
Marshal(obj interface{}) ([]byte, error)
Unmarshal(obj interface{}, buff []byte) error
IsInterfaceNil() bool
}
// ProfileChangeObserver defines the interface for observing profile changes
type ProfileChangeObserver interface {
OnProfileChanged()
}