-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
47 lines (36 loc) · 1.11 KB
/
options.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
package slogcolor
import (
"log/slog"
"time"
"github.com/fatih/color"
)
var DefaultOptions *Options = &Options{
Level: slog.LevelInfo,
TimeFormat: time.DateTime,
SrcFileMode: ShortFile,
SrcFileLength: 0,
MsgPrefix: color.HiWhiteString("| "),
MsgLength: 0,
MsgColor: color.New(),
NoColor: false,
}
type Options struct {
// Level reports the minimum level to log.
// Levels with lower levels are discarded.
// If nil, the Handler uses [slog.LevelInfo].
Level slog.Leveler
// TimeFormat is the time format.
TimeFormat string
// SrcFileMode is the source file mode.
SrcFileMode SourceFileMode
// SrcFileLength to show fixed length filename to line up the log output, default 0 shows complete filename.
SrcFileLength int
// MsgPrefix to show prefix before message, default: white colored "| ".
MsgPrefix string
// MsgColor is the color of the message, default to empty.
MsgColor *color.Color
// MsgLength to show fixed length message to line up the log output, default 0 shows complete message.
MsgLength int
// NoColor disables color, default: false.
NoColor bool
}