-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
63 lines (60 loc) · 2.48 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
58
59
60
61
62
63
package logger
import (
"context"
"errors"
)
var (
// ErrLogPathNotSet is an error that indicates the log path is not set.
ErrLogPathNotSet = errors.New("log path must be set")
)
// Logger is the interface for Logger types
type Logger interface {
// SetLevel set logger level
SetLevel(lv Level)
// WithContext with context
WithContext(ctx context.Context) Logger
// WithFields set fields to always be logged
WithFields(fields map[string]any) Logger
// WithCallDepth with logger call depth.
WithCallDepth(callDepth int) Logger
// Debug uses fmt.Sprint to construct and log a message.
Debug(args ...interface{})
// Info uses fmt.Sprint to construct and log a message.
Info(args ...interface{})
// Warn uses fmt.Sprint to construct and log a message.
Warn(args ...interface{})
// Error uses fmt.Sprint to construct and log a message.
Error(args ...interface{})
// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
Fatal(args ...interface{})
// Debugf uses fmt.Sprintf to log a templated message.
Debugf(template string, args ...interface{})
// Infof uses fmt.Sprintf to log a templated message.
Infof(template string, args ...interface{})
// Warnf uses fmt.Sprintf to log a templated message.
Warnf(template string, args ...interface{})
// Errorf uses fmt.Sprintf to log a templated message.
Errorf(template string, args ...interface{})
// Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
Fatalf(template string, args ...interface{})
// Debugw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
//
// When debug-level logging is disabled, this is much faster than
// s.With(keysAndValues).Debug(msg)
Debugw(msg string, keysAndValues ...interface{})
// Infow logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
Infow(msg string, keysAndValues ...interface{})
// Warnw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
Warnw(msg string, keysAndValues ...interface{})
// Errorw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
Errorw(msg string, keysAndValues ...interface{})
// Fatalw logs a message with some additional context, then calls os.Exit. The
// variadic key-value pairs are treated as they are in With.
Fatalw(msg string, keysAndValues ...interface{})
// Sync logger sync
Sync() error
}