/
types.go
64 lines (51 loc) · 1.76 KB
/
types.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
package logger
import (
"context"
"io"
"github.com/batazor/shortlink/internal/pkg/logger/field"
)
const (
// Zap implementation
Zap int = iota
// Logrus implementation
Logrus
)
// Logger is our contract for the logger
type Logger interface { // nolint:decorder
init(Configuration) error
Fatal(msg string, fields ...field.Fields)
FatalWithContext(ctx context.Context, msg string, fields ...field.Fields)
Error(msg string, fields ...field.Fields)
ErrorWithContext(ctx context.Context, msg string, fields ...field.Fields)
Warn(msg string, fields ...field.Fields)
WarnWithContext(ctx context.Context, msg string, fields ...field.Fields)
Info(msg string, fields ...field.Fields)
InfoWithContext(ctx context.Context, msg string, fields ...field.Fields)
Debug(msg string, fields ...field.Fields)
DebugWithContext(ctx context.Context, msg string, fields ...field.Fields)
Get() interface{}
// Closer is the interface that wraps the basic Close method.
io.Closer
}
// The severity levels. Higher values are more considered more important.
const (
// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
// logging level is set to Panic.
FATAL_LEVEL int = iota
// ErrorLevel level. Logs. Used for errors that should definitely be noted.
// Commonly used for hooks to send errors to an error tracking service.
ERROR_LEVEL
// WarnLevel level. Non-critical entries that deserve eyes.
WARN_LEVEL
// InfoLevel level. General operational entries about what's going on inside the
// application.
INFO_LEVEL
// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
DEBUG_LEVEL
)
// Configuration - options for logger
type Configuration struct { // nolint:decorder
Level int
Writer io.Writer
TimeFormat string
}