logger

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ASYNC_CHANNEL_SIZE = 10000

Variables

View Source
var Log = initLogger()

Log is the default logger

Functions

func DayLogRecord added in v0.1.0

func DayLogRecord(flag int, format string, v ...interface{})

异步写log

func Debug added in v0.1.0

func Debug(msg string, fields ...zapcore.Field)

Debug logger

func Debugf added in v0.1.0

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

Debugf logger

func Error added in v0.1.0

func Error(msg string, fields ...zapcore.Field)

Error logger

func Errorf added in v0.1.0

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

Errorf logger

func Fatal added in v0.1.0

func Fatal(msg string, fields ...zapcore.Field)

Fatal logger, log message then call os.Exit(-1).

func Info added in v0.1.0

func Info(msg string, fields ...zapcore.Field)

Info logger

func Infof added in v0.1.0

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

Infof logger

func Init added in v0.1.0

func Init(serverType string, config *viper.Viper)

Init logger initialize

func InitDayLog added in v0.1.0

func InitDayLog(v *viper.Viper) bool

异步写log的channel size

func Panic added in v0.1.0

func Panic(msg string, fields ...zapcore.Field)

Panic logger, log message then Panic

func Panicf added in v0.1.0

func Panicf(format string, args ...interface{})

Panicf logger, log message then Panic

func SetLogger

func SetLogger(l Logger)

SetLogger rewrites the default logger

func Warn added in v0.1.0

func Warn(msg string, fields ...zapcore.Field)

Warn logger

func Warnf added in v0.1.0

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

Warnf logger

Types

type AsyncMsg added in v0.1.0

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

type DayLog added in v0.1.0

type DayLog struct {
	Cfg        *LogConfig      //配置
	Instance   *logs.BeeLogger //日志实例
	LogName    string          //配置的名字
	Dir        string          //路径
	CurLogName string          //当前使用的名字
	CurHours   int             //当前点数
}

daylog

func (*DayLog) Info added in v0.1.0

func (d *DayLog) Info(format string, v ...interface{})

info

type DayLogMgr added in v0.1.0

type DayLogMgr struct {
	LogMap     map[int]*DayLog
	MsgChannel chan *AsyncMsg
}

beego logs模块单协程只支持单文件读写,不支持单协程多文件读写,daylog一般都是多文件读写,为节约资源,参照beego logs模块中的log.go文件改造

type LogConfig added in v0.1.0

type LogConfig struct {
	FilePath   string //文件路径
	FileName   string `json:"filename"` //文件名字
	Level      int    `json:"level"`    // 日志保存的时候的级别,默认是 Trace 级别
	Maxlines   int    `json:"maxlines"` // 每个文件保存的最大行数,默认值 1000000
	Maxsize    int    `json:"maxsize"`  // 每个文件保存的最大尺寸,默认值是 1 << 28, //256 MB
	Daily      bool   `json:"daily"`    // 是否按照每天 logrotate,默认是 true
	Maxdays    int    `json:"maxdays"`  // 文件最多保存多少天,默认保存 7 天
	Rotate     bool   `json:"rotate"`   // 是否开启 logrotate,默认是 true
	Perm       string `json:"perm"`     // 日志文件权限
	RotatePerm string `json:"rotateperm"`
	Color      bool   //是否支持颜色
}

type Logger

type Logger interface {
	Fatal(format ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalln(args ...interface{})

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(args ...interface{})
}

Logger represents the log interface

Jump to

Keyboard shortcuts

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