logs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

日志调度器 功能: 初始化各个日志处理器

使用: logger := logs.NewDispatcher() logger.SetTarget(logs.TARGET_FILE, `{"filename":"xxxx.log","level":10,"max_size":500,"rotate":true}`) logger.Error("这是一个错误") logger.Debug("这是一个调试") logger.Info("这是一个信息") logger.Warn("这是一个警告")

Index

Constants

View Source
const (
	TextBlack = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
)
View Source
const (
	LOG_ERROR = iota
	LOG_WARN
	LOG_INFO
	LOG_TRACE
	LOG_DEBUG
)

日志等级

View Source
const (
	TARGET_FILE    = "file"
	TARGET_CONSOLE = "console"
)

日志落地标志

Variables

This section is empty.

Functions

func Black

func Black(str string) string

func Blue

func Blue(str string) string

func Cyan

func Cyan(str string) string

func Green

func Green(str string) string

func Magenta

func Magenta(str string) string

func Red

func Red(str string) string

func RegisterTareget

func RegisterTareget(name string, tg target)

注册适配器

func White

func White(str string) string

func Yellow

func Yellow(str string) string

Types

type Dispatcher

type Dispatcher struct {
	Level   int
	Targets []*logTarget
}

调度器对象

func NewDispatcher

func NewDispatcher(lvl int) *Dispatcher

新建调度器

func (*Dispatcher) Debug

func (d *Dispatcher) Debug(msg ...interface{})

调试输出

func (*Dispatcher) Error

func (d *Dispatcher) Error(msg ...interface{})

错误输出

func (*Dispatcher) Info

func (d *Dispatcher) Info(msg ...interface{})

信息输出

func (*Dispatcher) SetTarget

func (d *Dispatcher) SetTarget(name string, config string)

设置日志处理对象(TAGET_FILE TAGET_CONSOLE)

func (*Dispatcher) Trace

func (d *Dispatcher) Trace(msg ...interface{})

追踪日志

func (*Dispatcher) Warn

func (d *Dispatcher) Warn(msg ...interface{})

警告输出

type LogCategory

type LogCategory string

Jump to

Keyboard shortcuts

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