logger

package
v0.0.0-...-79e39e7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LevelDescMap = map[LogLevel]string{
		FATAL: "FATAL",
		ERROR: "ERROR",
		WARN:  "WARN",
		INFO:  "INFO",
		DEBUG: "DEBUG",
	}
	DescLevelMap = map[string]LogLevel{
		"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{
		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 ...interface{})

func Debugf

func Debugf(txt string, args ...interface{})

func Error

func Error(txt ...interface{})

func Errorf

func Errorf(txt string, args ...interface{})

func Fatal

func Fatal(txt ...interface{})

func Fatalf

func Fatalf(txt string, args ...interface{})

func Info

func Info(txt ...interface{})

func Infof

func Infof(txt string, args ...interface{})

func PathExists

func PathExists(path string) (bool, error)

func SetLogger

func SetLogger(l *Logger, cancel context.CancelFunc)

func Warn

func Warn(txt ...interface{})

func Warnf

func Warnf(txt string, args ...interface{})

Types

type LogItem

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

type LogLevel

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

type Logger

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

func NewLogger

func NewLogger(options ...Option) (*Logger, context.CancelFunc)

func (*Logger) Debug

func (l *Logger) Debug(txt ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(tmp string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(txt ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(tmp string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(txt ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(tmp string, args ...interface{})

func (*Logger) GetCallerPath

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

func (*Logger) Info

func (l *Logger) Info(txt ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(tmp string, args ...interface{})

func (*Logger) NewLogItem

func (l *Logger) NewLogItem(level LogLevel, txt ...interface{}) *LogItem

func (*Logger) OpenFile

func (l *Logger) OpenFile()

func (*Logger) OutFile

func (l *Logger) OutFile(txt string)

func (*Logger) OutStd

func (l *Logger) OutStd(level LogLevel, txt string)

func (*Logger) Warn

func (l *Logger) Warn(txt ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(tmp string, args ...interface{})

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

func WithStdColor

func WithStdColor(show bool) Option

func WithTickTime

func WithTickTime(t time.Duration) Option

func WithTimeFormat

func WithTimeFormat(format string) Option

func WithZipDuration

func WithZipDuration(d time.Duration) Option

type OutType

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

Jump to

Keyboard shortcuts

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