Help us shape the future of Go! Take the 2026 Go Developer Survey

bunnystub

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: MIT Imports: 11 Imported by: 0

README

RollingWriter

Rolling file IO writer is write in go. Easy to ID nonlock rollig writer

Contribute && TODO

Any new feature inneed pls put up an issue

Documentation

Index

Constants

View Source
const (
	WithoutRotate = iota
	TimeRotate
	VolumeRotate
)

Variables

View Source
var (
	// BufferSize defined the buffer size
	// about 2MB
	BufferSize = 0x6ffffff

	// ErrInternal defined the internal error
	ErrInternal = errors.New("error internal")
	// ErrInvalidArgument defined the invalid argument
	ErrInvalidArgument = errors.New("error argument invalid")
	// ErrMakingLogDirFailed means this path can not be created
	ErrMakingLogDirFailed = errors.New("error in make dir with given path")
)
View Source
var (
	// Precision defined the precision about how many SECONDS will be waitted before
	// the reopen operation check the condition
	Precision = 1
)

Functions

This section is empty.

Types

type IOManager

type IOManager struct {
	FilePath string
	// file name js like this style: prefix-timestamp-suffix.log
	// compressed log file is named like this: prefix-timestamp-suffix.tar
	Prefix     string
	Suffix     string
	FileMod    os.FileMode
	IsIgnoreOK bool
	IsCompress bool
	IsLockFree bool

	// pattern is just like the crontable style without year, second minute hour day mounth weekday
	RollingTimePattern string
	// VolumeSize can be give a size with K M G
	RollingVolumeSize string
	// TimeFormatPattern defined the rolling time pattern which will used to name the .log file
	TimeFormatPattern string
	// contains filtered or unexported fields
}

func (*IOManager) Compress

func (m *IOManager) Compress() bool

func (*IOManager) Concurency

func (m *IOManager) Concurency() int

func (*IOManager) Enable

func (m *IOManager) Enable() chan string

func (*IOManager) FileMode

func (m *IOManager) FileMode() os.FileMode

func (*IOManager) IgnoreOK

func (m *IOManager) IgnoreOK() bool

func (*IOManager) LockFree

func (m *IOManager) LockFree() bool

func (*IOManager) NameParts

func (m *IOManager) NameParts() []string

func (*IOManager) ResetFileSize

func (m *IOManager) ResetFileSize()

func (*IOManager) Spining

func (m *IOManager) Spining() bool

func (*IOManager) WriteN

func (m *IOManager) WriteN(n int)

type IOWriter

type IOWriter interface {
	io.Writer
	Close() error
}

func NewIOWriter

func NewIOWriter(path string, kind RotatePolicy, ops ...Option) (IOWriter, error)

NewIOWriter generate a iofilter writer with given ioManager

type Manager

type Manager interface {
	Enable() chan string
	WriteN(int)
	ResetFileSize()
	LockFree() bool
	NameParts() []string
	FileMode() os.FileMode
	Compress() bool
	IgnoreOK() bool
	Concurency() int
	Spining() bool
}

func NewTimeRotateManager

func NewTimeRotateManager(ops ...Option) Manager

func NewVolumeRotateManager

func NewVolumeRotateManager(ops ...Option) Manager

type Option

type Option func(*IOManager)

func WithCompress

func WithCompress() Option

func WithConcurrency

func WithConcurrency(concurency int, spining bool) Option

func WithDir

func WithDir(dir string) Option

func WithFileMode

func WithFileMode(mode uint32) Option

func WithIgnoreOK

func WithIgnoreOK() Option

func WithLockFree

func WithLockFree() Option

func WithPath

func WithPath(path string) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithSuffix

func WithSuffix(suffix string) Option

func WithTimePattern

func WithTimePattern(pattern string) Option

func WithVolumeSize

func WithVolumeSize(size string) Option

type RotatePolicy

type RotatePolicy int

Jump to

Keyboard shortcuts

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