- move LogLevel and predefined levels into levels.go - add level-specific constructors for info/warn/error/fatal/debug - add predefined HTTP method log levels and LogLevelForMethod - unify Logger Print/Println internals and add Printf - improve GoDoc coverage for exported APIs
This commit is contained in:
@@ -5,12 +5,25 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FgColor is a basic ANSI foreground color code.
|
||||
type FgColor uint8
|
||||
|
||||
// BgColor is a basic ANSI background color code.
|
||||
type BgColor uint8
|
||||
|
||||
// FgColor256 is an ANSI 256-color foreground value.
|
||||
type FgColor256 uint8
|
||||
|
||||
// BgColor256 is an ANSI 256-color background value.
|
||||
type BgColor256 uint8
|
||||
|
||||
// BgColorRGB is an ANSI truecolor background value encoded as RGB bytes.
|
||||
type BgColorRGB []uint8
|
||||
|
||||
// FgColorRGB is an ANSI truecolor foreground value encoded as RGB bytes.
|
||||
type FgColorRGB []uint8
|
||||
|
||||
// Attribute is an ANSI text attribute code.
|
||||
type Attribute uint8
|
||||
|
||||
// NewBgColorRGB builds an RGB background color value.
|
||||
@@ -23,6 +36,7 @@ func NewFgColorRGB(r, g, b uint8) FgColorRGB {
|
||||
return FgColorRGB{r, g, b}
|
||||
}
|
||||
|
||||
// Text attribute codes.
|
||||
const (
|
||||
Reset Attribute = iota
|
||||
Bold
|
||||
@@ -35,6 +49,8 @@ const (
|
||||
Conceal
|
||||
CrossedOut
|
||||
)
|
||||
|
||||
// Additional text attribute codes.
|
||||
const (
|
||||
DoubleUnderline Attribute = iota + 21 // Can be disable bold on some terminals
|
||||
DisableBold
|
||||
@@ -45,6 +61,8 @@ const (
|
||||
DisableConceal
|
||||
DisableCrossedOut
|
||||
)
|
||||
|
||||
// Basic foreground color codes.
|
||||
const (
|
||||
FgNone = 0
|
||||
FgBlack FgColor = iota + 30
|
||||
@@ -57,6 +75,8 @@ const (
|
||||
FgWhite
|
||||
FgDefault FgColor = 39
|
||||
)
|
||||
|
||||
// Basic background color codes.
|
||||
const (
|
||||
BgNone = 0
|
||||
BgBlack BgColor = iota + 40
|
||||
@@ -69,6 +89,8 @@ const (
|
||||
BgWhite
|
||||
BgDefault BgColor = 49
|
||||
)
|
||||
|
||||
// High-intensity foreground color codes.
|
||||
const (
|
||||
FgHiBlack FgColor = iota + 90
|
||||
FgHiRed
|
||||
@@ -79,6 +101,8 @@ const (
|
||||
FgHiCyan
|
||||
FgHiWhite
|
||||
)
|
||||
|
||||
// High-intensity background color codes.
|
||||
const (
|
||||
BgHiBlack BgColor = iota + 100
|
||||
BgHiRed
|
||||
@@ -90,7 +114,7 @@ const (
|
||||
BgHiWhite
|
||||
)
|
||||
|
||||
// This attributes rarely used and not supported by all terminals.
|
||||
// Rarely used text attribute codes that are not supported by all terminals.
|
||||
const (
|
||||
Border Attribute = iota + 51
|
||||
Outline
|
||||
@@ -99,6 +123,7 @@ const (
|
||||
DisableUpperline
|
||||
)
|
||||
|
||||
// ColorStringBuilder incrementally builds ANSI-colored strings.
|
||||
type ColorStringBuilder struct {
|
||||
str string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user