logger

package
v2.10.18 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LevelDescMap = map[LogLevel]string{
		REPORT: "REPORT",
		FATAL:  "FATAL",
		ERROR:  "ERROR",
		WARN:   "WARN",
		INFO:   "INFO",
		DEBUG:  "DEBUG",
	}
	DescLevelMap = map[string]LogLevel{
		"report": REPORT,
		"fatal":  FATAL,
		"error":  ERROR,
		"warn":   WARN,
		"info":   INFO,
		"debug":  DEBUG,
	}
	DescOutTypeMap = map[string]OutType{
		"out_std":  OutStd,
		"out_file": OutFile,
		"out_all":  OutAll,
	}
	LevelColorMap = map[LogLevel]*color.Color{
		REPORT: color.New(color.FgHiWhite),
		FATAL:  color.New(color.FgHiMagenta),
		ERROR:  color.New(color.FgHiRed),
		WARN:   color.New(color.FgHiYellow),
		INFO:   color.New(color.FgHiBlue),
		DEBUG:  color.New(color.FgHiCyan),
	}
)

Functions

func Compress

func Compress(files []*os.File, dest string) error

压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func CompressZip

func CompressZip(src string, dest string) (err error)

func DeCompress

func DeCompress(zipFile, dest string) (err error)

解压

func DeCompressFile

func DeCompressFile(file *zip.File, dest string) error

func Debug

func Debug(txt ...any)

func Debugf

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

func Error

func Error(txt ...any)

func Errorf

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

func Fatal

func Fatal(txt ...any)

func Fatalf

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

func Info

func Info(txt ...any)

func Infof

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

func PathExists

func PathExists(path string) (bool, error)

func Report added in v2.0.5

func Report(txt ...any)

func Reportf added in v2.0.5

func Reportf(txt string, args ...any)

func SetLogger

func SetLogger(l *Logger)

func Warn

func Warn(txt ...any)

func Warnf

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

Types

type ChangChanType added in v2.4.3

type ChangChanType int
const (
	ChangChanZip  ChangChanType = iota //改变zip chan
	ChangChanDump                      // 改变dump chan
)

type LogItem

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

type LogLevel

type LogLevel int
const (
	REPORT LogLevel = iota //0-上报
	FATAL                  //1-致命错误
	ERROR                  //2-错误
	WARN                   //3-警告
	INFO                   //4-通知
	DEBUG                  //5-调试
)

type Logger

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

func NewLogger

func NewLogger(options ...Option) *Logger

func WithSuffix added in v2.5.7

func WithSuffix(suffix string) *Logger

func (*Logger) Debug

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

func (*Logger) Debugf

func (l *Logger) Debugf(tmp string, args ...any)

func (*Logger) Error

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

func (*Logger) Errorf

func (l *Logger) Errorf(tmp string, args ...any)

func (*Logger) Fatal

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

func (*Logger) Fatalf

func (l *Logger) Fatalf(tmp string, args ...any)

func (*Logger) GetCallerPath

func (l *Logger) GetCallerPath(file string) string

func (*Logger) Info

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

func (*Logger) Infof

func (l *Logger) Infof(tmp string, args ...any)

func (*Logger) NewLogItem

func (l *Logger) NewLogItem(level LogLevel, txt ...any) *LogItem

func (*Logger) Report added in v2.0.5

func (l *Logger) Report(txt ...any)

func (*Logger) Reportf added in v2.0.5

func (l *Logger) Reportf(tmp string, args ...any)

func (*Logger) Warn

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

func (*Logger) Warnf

func (l *Logger) Warnf(tmp string, args ...any)

func (*Logger) WithSuffix added in v2.5.7

func (l *Logger) WithSuffix(suffix string) *Logger

type Option

type Option func(l *Logger)

func WithLogDir

func WithLogDir(dir string) Option

func WithLogDump

func WithLogDump(dump bool) Option

func WithLogLevel

func WithLogLevel(level string) Option

func WithLogName

func WithLogName(name string) Option

func WithLogRuntime

func WithLogRuntime(record bool) Option

func WithOutType

func WithOutType(typ string) Option

------------------writer-------------

func WithReporter added in v2.3.3

func WithReporter(reporter Reporter) Option

func WithStdColor

func WithStdColor(show bool) Option

func WithTimeFormat

func WithTimeFormat(format string) Option

type OutType

type OutType int
const (
	OutStd  OutType = iota //0-标准输出
	OutFile                //1-文件输出
	OutAll                 //2-文件和标准都输出
)

type Reporter added in v2.3.3

type Reporter func(ctx string)

type Writer added in v2.1.4

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

func (*Writer) OpenFile added in v2.1.4

func (w *Writer) OpenFile()

func (*Writer) OutFile added in v2.1.4

func (w *Writer) OutFile(txt string)

func (*Writer) OutStd added in v2.1.4

func (w *Writer) OutStd(level LogLevel, txt string)

Jump to

Keyboard shortcuts

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