logx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const Levels = 6

Variables

View Source
var Colors = map[Level]string{
	DEBUG: "34",
	INFO:  "32",
	WARN:  "33",
	ERROR: "31",
	FATAL: "35",
}
View Source
var Labels = map[Level]string{
	DEBUG: "DEBUG",
	INFO:  "INFO",
	WARN:  "WARN",
	ERROR: "ERROR",
	FATAL: "FATAL",
}
View Source
var Layouts = []string{
	Year:   "2006",
	Month:  "2006-01",
	Day:    "2006-01-02",
	Hour:   "2006-01-02 15:00",
	Minute: "2006-01-02 15:04",
	Second: "2006-01-02 15:04:05",
}

Functions

func Debug

func Debug(args ...any)

func Debugf

func Debugf(format string, args ...any)

func Error

func Error(args ...any)

func Errorf

func Errorf(format string, args ...any)

func Fatal

func Fatal(args ...any)

func Fatalf

func Fatalf(format string, args ...any)

func Info

func Info(args ...any)

func Infof

func Infof(format string, args ...any)

func SetDefault

func SetDefault(nlog Logger)

func Warn

func Warn(args ...any)

func Warnf

func Warnf(format string, args ...any)

Types

type Appender

type Appender interface {
	Write(level Level, args ...any)
}

type CKind

type CKind = uint
const (
	CLabel CKind = iota
	CMsg
	CLabelMsg
	CAll
)

type ConsoleAppender

type ConsoleAppender struct {
	Prefix     string
	TimeLayout string
	ColorOff   bool
	ColorKind  CKind
	Colors     map[Level]string
	// contains filtered or unexported fields
}

func (*ConsoleAppender) Write

func (it *ConsoleAppender) Write(level Level, args ...any)

type FileAppender

type FileAppender struct {
	TimeLayout string      // layout for time formatting
	MaxSize    int64       // max size of log file
	Name       string      // name of log file
	FileFlag   int         // FileFlag to open log file
	FileMode   os.FileMode // FileMode to open log file
	Prefix     string      // prefix of messages
	CycleOff   bool        // do not use the period cycle
	Cycle      RollCycle   // rolling cycle
	OutDir     string      // output directory cycle
	Split      Split       // split different level into different log file
	// contains filtered or unexported fields
}

func (*FileAppender) Write

func (it *FileAppender) Write(level Level, args ...any)

type Level

type Level = int
const (
	ALL Level = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
	OFF
)

type Logger

type Logger interface {
	SetLevel(level Level)
	GetLevel() Level
	Debug(args ...any)
	Debugf(format string, args ...any)
	Info(args ...any)
	Infof(format string, args ...any)
	Warn(args ...any)
	Warnf(format string, args ...any)
	Error(args ...any)
	Errorf(format string, args ...any)
	Fatal(args ...any)
	Fatalf(format string, args ...any)
}

func Default

func Default() Logger

func LoggerOf

func LoggerOf(appender Appender) Logger

type Proxy

type Proxy struct {
	Level    Level
	Appender Appender
}

func (*Proxy) Debug

func (it *Proxy) Debug(args ...any)

func (*Proxy) Debugf

func (it *Proxy) Debugf(format string, args ...any)

func (*Proxy) Error

func (it *Proxy) Error(args ...any)

func (*Proxy) Errorf

func (it *Proxy) Errorf(format string, args ...any)

func (*Proxy) Fatal

func (it *Proxy) Fatal(args ...any)

func (*Proxy) Fatalf

func (it *Proxy) Fatalf(format string, args ...any)

func (*Proxy) GetLevel

func (it *Proxy) GetLevel() Level

func (*Proxy) Info

func (it *Proxy) Info(args ...any)

func (*Proxy) Infof

func (it *Proxy) Infof(format string, args ...any)

func (*Proxy) SetLevel

func (it *Proxy) SetLevel(level Level)

func (*Proxy) Warn

func (it *Proxy) Warn(args ...any)

func (*Proxy) Warnf

func (it *Proxy) Warnf(format string, args ...any)

type RollCycle

type RollCycle int
const (
	Day RollCycle = iota
	Minute
	Hour
	Week
	Month
	Year
	Second
)

type Split

type Split = [Levels]bool

Jump to

Keyboard shortcuts

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