logs

package
v0.0.0-...-740bfc4 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFactory

func GetFactory() *logFactory

func NewConsoleLogger

func NewConsoleLogger(filePath string, level zapcore.Level, maxSize int, maxBackups int, maxAge int, compress bool, serviceName string) *zap.Logger

func NewLogger

func NewLogger(filePath string, level zapcore.Level, maxSize int, maxBackups int, maxAge int, compress bool, serviceName string) *zap.Logger

*

  • 获取日志
  • filePath 日志文件路径
  • level 日志级别
  • maxSize 每个日志文件保存的最大尺寸 单位:M
  • maxBackups 日志文件最多保存多少个备份
  • maxAge 文件最多保存多少天
  • compress 是否压缩
  • serviceName 服务名

Types

type Level

type Level int8
const (
	ERROR Level = -1
	DEBUG Level = 0
	INFO  Level = 1
)

type Log

type Log interface {
	Debug(string) string
	Error(string) string
	Info(string) string
}

type LogHandler

type LogHandler func(string) error

type LogHook

type LogHook interface {
	OnLog(string, Level)
}

type LogOptions

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

func (*LogOptions) Compress

func (o *LogOptions) Compress(value bool) *LogOptions

func (*LogOptions) Debug

func (o *LogOptions) Debug(value bool) *LogOptions

func (*LogOptions) FileName

func (o *LogOptions) FileName(file string) *LogOptions

func (*LogOptions) FileSize

func (o *LogOptions) FileSize(value int) *LogOptions

func (*LogOptions) Handler

func (o *LogOptions) Handler(value LogHandler) *LogOptions

func (*LogOptions) Hook

func (o *LogOptions) Hook(value LogHook) *LogOptions

func (*LogOptions) Json

func (o *LogOptions) Json(value bool) *LogOptions

func (*LogOptions) MaxFileCount

func (o *LogOptions) MaxFileCount(value int) *LogOptions

type Logger

type Logger interface {
	Debug(string, ...interface{})
	Error(string, ...interface{})
	Info(string, ...interface{})
	Log(string, Level, ...interface{})
}

func Get

func Get() Logger

type LoggerCreator

type LoggerCreator interface {
	Create(options *LogOptions) (Log, error)
}

Jump to

Keyboard shortcuts

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