filewriter

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RotateDaily = "2006-01-02"
)

RotateFormat

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

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

FileWriter create file log writer

func New

func New(fpath string, fns ...Option) (*FileWriter, error)

New FileWriter A FileWriter is safe for use by multiple goroutines simultaneously.

func (*FileWriter) Close

func (f *FileWriter) Close() error

Close close file writer

func (*FileWriter) Write

func (f *FileWriter) Write(p []byte) (int, error)

Write write data to log file, return write bytes is pseudo just for implement io.Writer.

type Option

type Option func(opt *option)

Option filewriter option

func ChanSize

func ChanSize(n int) Option

ChanSize set internal chan size default 8192 use about 64k memory on x64 platfrom static, because filewriter has internal object pool, change chan size bigger may cause filewriter use a lot of memory, because sync.Pool can't set expire time memory won't free until program exit.

func MaxFile

func MaxFile(n int) Option

MaxFile default 999, 0 meaning unlimit. TODO: don't create file list if MaxSize is unlimt.

func MaxSize

func MaxSize(n int64) Option

MaxSize set max size for single log file, defult 1GB, 0 meaning unlimit.

func RotateFormat

func RotateFormat(format string) Option

RotateFormat e.g 2006-01-02 meaning rotate log file every day. NOTE: format can't contain ".", "." will cause panic ヽ(*。>Д<)o゜.

Jump to

Keyboard shortcuts

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