-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinterface.go
More file actions
86 lines (77 loc) · 2.14 KB
/
interface.go
File metadata and controls
86 lines (77 loc) · 2.14 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2018-2022 KIDTSUNAMI
// Author: alex@kidtsunami.com
package log
import (
"io"
stdlog "log"
"github.com/fatih/color"
)
type LogFn func(...any)
type LogfFn func(string, ...any)
type Level byte
var Noop = func(string, ...any) {}
const (
LevelTrace Level = iota
LevelDebug
LevelInfo
LevelWarn
LevelError
LevelFatal
LevelOff
LevelInvalid
)
var (
ColorTrace = color.FgHiBlue
ColorDebug = color.FgCyan
ColorInfo = color.FgGreen
ColorWarn = color.FgYellow
ColorError = color.FgRed
ColorFatal = color.FgMagenta
)
type Logger interface {
Noop(...any)
Trace(...any)
Tracef(string, ...any)
Debug(...any)
Debugf(string, ...any)
Info(...any)
Infof(string, ...any)
Warn(...any)
Warnf(string, ...any)
Error(...any)
Errorf(string, ...any)
Fatal(...any)
Fatalf(string, ...any)
Panic(...any)
Panicf(string, ...any)
Level() Level
IsColor() bool
SetLevel(Level) Logger
SetLevelString(string) Logger
Logger() *stdlog.Logger
Clone(string) Logger
WithTag(string) Logger
WithRegistry(*Registry) Logger
WithSampler(*Sampler) Logger
WithColor(bool) Logger
WithFlags(int) Logger
Attach(io.Writer)
Detach(io.Writer)
}
// package level forwarders to the real logger implementation
func Trace(v ...any) { Log.Trace(v...) }
func Tracef(s string, v ...any) { Log.Tracef(s, v...) }
func Error(v ...any) { Log.Error(v...) }
func Errorf(s string, v ...any) { Log.Errorf(s, v...) }
func Warn(v ...any) { Log.Warn(v...) }
func Warnf(s string, v ...any) { Log.Warnf(s, v...) }
func Info(v ...any) { Log.Info(v...) }
func Infof(s string, v ...any) { Log.Infof(s, v...) }
func Debug(v ...any) { Log.Debug(v...) }
func Debugf(s string, v ...any) { Log.Debugf(s, v...) }
func Fatal(v ...any) { Log.Fatal(v...) }
func Fatalf(s string, v ...any) { Log.Fatalf(s, v...) }
func Panic(v ...any) { Log.Panic(v...) }
func Panicf(s string, v ...any) { Log.Panicf(s, v...) }
func SetLevel(l Level) Logger { Log.SetLevel(l); return Log }
func SetLevelString(l string) Logger { return SetLevel(ParseLevel(l)) }