-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
42 lines (33 loc) · 1.01 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
package slogcolor
import (
"github.com/fatih/color"
"log/slog"
"time"
)
var DefaultOptions *Options = &Options{
Level: slog.LevelInfo,
TimeFormat: time.DateTime,
SrcFileMode: ShortFile,
SrcFileLength: 0,
MsgPrefix: color.HiWhiteString("| "),
MsgLength: 0,
MsgColor: color.New(),
}
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
// 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
}