This repository was archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.go
More file actions
68 lines (52 loc) · 2.09 KB
/
logger.go
File metadata and controls
68 lines (52 loc) · 2.09 KB
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
package log
// LabelName is a name for a Message label. Can only contain A-Z, a-z, 0-9, -, _.
type LabelName string
// LabelValue is a string, int, bool, or float.
type LabelValue interface{}
// Labels is a map linking
type Labels map[LabelName]LabelValue
// Logger The logger interface provides logging facilities on various levels.
type Logger interface {
// WithLevel returns a copy of the logger for a specified log level. Panics if the log level provided is invalid.
WithLevel(level Level) Logger
// WithLabel returns a logger with an added label (e.g. username, IP, etc.) Panics if the label name is empty.
WithLabel(labelName LabelName, labelValue LabelValue) Logger
// Debug logs a message at the debug level.
Debug(message ...interface{})
// Info logs a message at the info level.
Info(message ...interface{})
// Notice logs a message at the notice level.
Notice(message ...interface{})
// Warning logs a message at the warning level.
Warning(message ...interface{})
// Error logs a message at the error level.
Error(message ...interface{})
// Critical logs a message at the critical level.
Critical(message ...interface{})
// Alert logs a message at the alert level.
Alert(message ...interface{})
// Emergency logs a message at the emergency level.
Emergency(message ...interface{})
// Log logs a number of objects or strings to the log.
Log(v ...interface{})
// Logf formats a message and logs it.
Logf(format string, v ...interface{})
// Rotate triggers the logging backend to close all connections and reopen them to allow for rotating log files.
Rotate() error
// Close closes the logging backend.
Close() error
}
// LoggerFactory is a factory to create a logger on demand
type LoggerFactory interface {
// Make creates a new logger with the specified configuration and module.
//
// - config is the configuration structure.
//
// Return:
//
// - Logger is the logger created.
// - error is returned if the configuration was invalid.
Make(config Config) (Logger, error)
// MustMake is identical to Make but panics if an error happens
MustMake(config Config) Logger
}