dlog

package
v0.0.0-...-800adf3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: ISC Imports: 11 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorBlack   = Color(0)
	ColorRed     = Color(1)
	ColorGreen   = Color(2)
	ColorYellow  = Color(3)
	ColorBlue    = Color(4)
	ColorMagenta = Color(5)
	ColorCyan    = Color(6)
	ColorWhite   = Color(7)
)

Functions

func Colorize

func Colorize(color Color, text string) string

func IsCharDevice

func IsCharDevice(file *os.File) (bool, error)

Types

type Backend

type Backend interface {
	Log(Message)
}

type BackendType

type BackendType string
const (
	BackendTypeTerminal BackendType = "terminal"
)

type Color

type Color int

type Data

type Data map[string]Datum

func MergeData

func MergeData(dataList ...Data) Data

type Datum

type Datum interface{}

type Level

type Level string
const (
	LevelDebug Level = "debug"
	LevelInfo  Level = "info"
	LevelError Level = "error"
)

type Logger

type Logger struct {
	Cfg        LoggerCfg
	Backend    Backend
	Domain     string
	Data       Data
	DebugLevel int
}

func DefaultLogger

func DefaultLogger(name string) *Logger

func NewLogger

func NewLogger(name string, cfg LoggerCfg) (*Logger, error)

func (*Logger) Child

func (l *Logger) Child(domain string, data Data) *Logger

func (*Logger) Debug

func (l *Logger) Debug(level int, format string, args ...interface{})

func (*Logger) DebugData

func (l *Logger) DebugData(data Data, level int, format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

func (*Logger) ErrorData

func (l *Logger) ErrorData(data Data, format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

func (*Logger) InfoData

func (l *Logger) InfoData(data Data, format string, args ...interface{})

func (*Logger) Log

func (l *Logger) Log(msg Message)

func (*Logger) StdLogger

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

func (*Logger) Write

func (l *Logger) Write(data []byte) (int, error)

type LoggerCfg

type LoggerCfg struct {
	BackendType BackendType      `json:"backend_type"`
	BackendData *json.RawMessage `json:"backend,omitempty"`
	Backend     interface{}      `json:"-"`
	DebugLevel  int              `json:"debug_level"`
}

func (*LoggerCfg) Check

func (cfg *LoggerCfg) Check(c *check.Checker)

type Message

type Message struct {
	Time       *time.Time
	Level      Level
	DebugLevel int
	Message    string
	Data       Data
	// contains filtered or unexported fields
}

type TerminalBackend

type TerminalBackend struct {
	Cfg TerminalBackendCfg
	// contains filtered or unexported fields
}

func NewTerminalBackend

func NewTerminalBackend(cfg TerminalBackendCfg) *TerminalBackend

func (*TerminalBackend) Colorize

func (b *TerminalBackend) Colorize(color Color, s string) string

func (*TerminalBackend) Log

func (b *TerminalBackend) Log(msg Message)

type TerminalBackendCfg

type TerminalBackendCfg struct {
	Color       bool `json:"color"`
	DomainWidth int  `json:"domain_width"`
}

Jump to

Keyboard shortcuts

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