rotatelog

package module
v0.0.0-...-459aebd Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 9 Imported by: 0

README

log

一个go语言的日志切割模块 兼容标准log,增添日志分级,类比logrotate修改增添按照配置时间转储压缩日志。具体使用见测试文件TestRotate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level describes the level of a log message.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelNotice
	LevelWarning
	LevelError
	LevelCritical
)

func NewLevel

func NewLevel(name string) Level

func (Level) String

func (l Level) String() string

String returns the string representation of the log level

type Logger

type Logger struct {
	*log.Logger
	Level Level
	// contains filtered or unexported fields
}

func New

func New(out io.Writer, prefix string, flag int, level Level, rc *RotateConfig) *Logger

@see log.New

func (*Logger) Critical

func (l *Logger) Critical(format string, v ...interface{})

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

leveled log function for easy use.

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) Log

func (l *Logger) Log(level Level, format string, v ...interface{})

func (*Logger) Notice

func (l *Logger) Notice(format string, v ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Rotate

func (l *Logger) Rotate() (err error)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) StartRotate

func (l *Logger) StartRotate() (err error)

func (*Logger) Stop

func (l *Logger) Stop()

func (*Logger) Warning

func (l *Logger) Warning(format string, v ...interface{})

type RotateConfig

type RotateConfig struct {
	Rotate   int           // keeped log files count
	Duration time.Duration // log rotate duration
	Compress bool
}

Jump to

Keyboard shortcuts

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