default_logger

package
v0.0.0-...-775528f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colorize

func Colorize(color uint, message any) string

func New

func New(options Options) log.Logger

Types

type Color

type Color uint

A Color type is a color. It can contain one background color, one foreground color and a format, including ideogram related formats.

const (
	BoldFm       Color = 1 << iota // 1
	FaintFm                        // 2
	ItalicFm                       // 3
	UnderlineFm                    // 4
	SlowBlinkFm                    // 5
	RapidBlinkFm                   // 6
	ReverseFm                      // 7
	ConcealFm                      // 8
	CrossedOutFm                   // 9

	FrakturFm         // 20
	DoublyUnderlineFm // 21 or bold off for some systems

	FramedFm    // 51
	EncircledFm // 52
	OverlinedFm // 53

	InverseFm       = ReverseFm    // alias to ReverseFm
	BlinkFm         = SlowBlinkFm  // alias to SlowBlinkFm
	HiddenFm        = ConcealFm    // alias to ConcealFm
	StrikeThroughFm = CrossedOutFm // alias to CrossedOutFm

)

Special formats

const (
	BlackFg   Color = (iota << shiftFg) | flagFg // 30, 90
	RedFg                                        // 31, 91
	GreenFg                                      // 32, 92
	YellowFg                                     // 33, 93
	BlueFg                                       // 34, 94
	MagentaFg                                    // 35, 95
	CyanFg                                       // 36, 96
	WhiteFg                                      // 37, 97

	BrightFg Color = ((1 << 3) << shiftFg) | flagFg // -> 90

	// BrownFg represents brown foreground color.
	//
	// Deprecated: use YellowFg instead, following specifications
	BrownFg = YellowFg
)

Foreground colors and related formats

const (
	BlackBg   Color = (iota << shiftBg) | flagBg // 40, 100
	RedBg                                        // 41, 101
	GreenBg                                      // 42, 102
	YellowBg                                     // 43, 103
	BlueBg                                       // 44, 104
	MagentaBg                                    // 45, 105
	CyanBg                                       // 46, 106
	WhiteBg                                      // 47, 107

	BrightBg Color = ((1 << 3) << shiftBg) | flagBg // -> 100

	// BrownBg represents brown foreground color.
	//
	// Deprecated: use YellowBg instead, following specifications
	BrownBg = YellowBg
)

Background colors and related formats

func (Color) IsValid deprecated

func (c Color) IsValid() bool

IsValid returns true always

Deprecated: don't use this method anymore

func (Color) Nos

func (c Color) Nos(zero bool) string

Nos returns string like 1;7;31;45. It may be an empty string for empty color. If the zero is true, then the string is prepended with 0;

type Formatter

type Formatter struct {
	BaseTime         time.Time
	DisableColors    bool
	DisableTimestamp bool
	FullTimestamp    bool
	DisableLineBreak bool
}

func (Formatter) Format

func (f Formatter) Format(ctx context.Context, level log.Level, tag string, message string, timestamp time.Time) string

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

func (*Logger) DebugContext

func (l *Logger) DebugContext(ctx context.Context, args ...any)

func (*Logger) Error

func (l *Logger) Error(args ...any)

func (*Logger) ErrorContext

func (l *Logger) ErrorContext(ctx context.Context, args ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(args ...any)

func (*Logger) FatalContext

func (l *Logger) FatalContext(ctx context.Context, args ...any)

func (*Logger) Info

func (l *Logger) Info(args ...any)

func (*Logger) InfoContext

func (l *Logger) InfoContext(ctx context.Context, args ...any)

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, level log.Level, args []any)

func (*Logger) Panic

func (l *Logger) Panic(args ...any)

func (*Logger) PanicContext

func (l *Logger) PanicContext(ctx context.Context, args ...any)

func (*Logger) Trace

func (l *Logger) Trace(args ...any)

func (*Logger) TraceContext

func (l *Logger) TraceContext(ctx context.Context, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

func (*Logger) WarnContext

func (l *Logger) WarnContext(ctx context.Context, args ...any)

func (*Logger) WithLevel

func (l *Logger) WithLevel(level log.Level) log.Logger

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(prefix string) log.Logger

type Options

type Options struct {
	Level          log.Level
	Writer         io.Writer
	BaseTime       time.Time
	PlatformWriter io.Writer
	DisableColor   bool
	Timestamp      bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL