@@ -11,6 +11,7 @@ import (
1111type (
1212 FormatMode string
1313 SourceMode string
14+ ColorMode string
1415)
1516
1617const (
@@ -22,13 +23,22 @@ const (
2223 SourceModeFile SourceMode = "file"
2324 SourceModeFull SourceMode = "full"
2425
26+ ColorModeDisabled ColorMode = "disabled"
27+ ColorModeEnabled ColorMode = "enabled"
28+ ColorModeAuto ColorMode = "auto"
29+
2530 LevelTrace = slog .Level (- 8 )
2631 LevelDebug = slog .LevelDebug
2732 LevelInfo = slog .LevelInfo
2833 LevelWarn = slog .LevelWarn
2934 LevelError = slog .LevelError
3035 LevelFatal = slog .Level (12 )
3136 LevelPanic = slog .Level (255 )
37+
38+ ColorError = 1
39+ ColorWarning = 3
40+ ColorInfo = 2
41+ ColorDebug = 5
3242)
3343
3444type (
@@ -37,19 +47,20 @@ type (
3747 }
3848
3949 logLevel struct {
40- text string
50+ text string
51+ color uint8
4152 }
4253)
4354
4455var (
4556 levelNames = map [slog.Leveler ]logLevel {
46- LevelTrace : {text : "TRACE" },
47- LevelDebug : {text : "DEBUG" },
48- LevelInfo : {text : "INFO" },
49- LevelWarn : {text : "WARN" },
50- LevelError : {text : "ERROR" },
51- LevelFatal : {text : "FATAL" },
52- LevelPanic : {text : "PANIC" },
57+ LevelTrace : {text : "TRACE" , color : ColorDebug },
58+ LevelDebug : {text : "DEBUG" , color : ColorDebug },
59+ LevelInfo : {text : "INFO" , color : ColorInfo },
60+ LevelWarn : {text : "WARN" , color : ColorWarning },
61+ LevelError : {text : "ERROR" , color : ColorError },
62+ LevelFatal : {text : "FATAL" , color : ColorError },
63+ LevelPanic : {text : "PANIC" , color : ColorError },
5364 }
5465)
5566
0 commit comments