rotate

package
v0.0.0-...-45da7de Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMaxFileIndex

func FindMaxFileIndex(path string, dotGz string) (int, string)

FindMaxFileIndex finds the maxIndex index of a file like log-2021-05-27_00001.log.

func GetFileIndex

func GetFileIndex(path string) int

func ParseOutputPath

func ParseOutputPath(c *Config, outputPath string) string

func SetFileIndex

func SetFileIndex(path string, index int) string

func SplitBaseIndexExt

func SplitBaseIndexExt(path string) (base, index, ext string)

Types

type Config

type Config struct {
	context.Context
	OutChanSize    int           // 通道大小
	AllowDiscarded bool          // 是否允许放弃(来不及写入)
	Append         bool          // 追加模式
	MaxSize        uint64        // 单个文件最大大小
	KeepDays       int           // 保留多少天的日志,过期删除, 0全部, 默认10天
	FlushLatency   time.Duration // 刷新延迟
}

type FileWriter

type FileWriter struct {
	FnTemplate string
	MaxSize    uint64
	Append     bool

	DotGz string

	MaxKeepDays int
	// contains filtered or unexported fields
}

func NewFileWriter

func NewFileWriter(fnTemplate string, maxSize uint64, append bool, maxKeepDays int) *FileWriter

func (*FileWriter) Close

func (w *FileWriter) Close() error

func (*FileWriter) Flush

func (w *FileWriter) Flush() error

func (*FileWriter) NewTimedFilename

func (w *FileWriter) NewTimedFilename(template, dotGz string) string

func (*FileWriter) RotateFilename

func (w *FileWriter) RotateFilename(fn string) string

func (*FileWriter) Write

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

type Flusher

type Flusher interface {
	Flush() error
}

type LfLog

type LfLog struct{}

func (LfLog) Flush

func (l LfLog) Flush() error

func (LfLog) Write

func (l LfLog) Write(p []byte) (n int, err error)

type LfStdout

type LfStdout struct {
	io.Writer
}

func (LfStdout) Flush

func (l LfStdout) Flush() error

func (LfStdout) Write

func (l LfStdout) Write(p []byte) (n int, err error)

type Option

type Option func(*Config)

func WithAllowDiscard

func WithAllowDiscard(v bool) Option

func WithAppend

func WithAppend(v bool) Option

func WithConfig

func WithConfig(v *Config) Option

func WithContext

func WithContext(v context.Context) Option

func WithFlushLatency

func WithFlushLatency(v time.Duration) Option

func WithKeepDays

func WithKeepDays(v int) Option

func WithMaxSize

func WithMaxSize(v uint64) Option

func WithOutChanSize

func WithOutChanSize(v int) Option

type QueueWriter

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

QueueWriter output parsed http messages

func NewQueueWriter

func NewQueueWriter(outputPath string, options ...Option) *QueueWriter

NewQueueWriter creates a new QueueWriter. outputPath: 1. stdout for the stdout 2. somepath/yyyyMMdd.log for the disk file 2.1. somepath/yyyyMMdd.log:append for the disk file for append mode 2.2. somepath/yyyyMMdd.log:100m for the disk file max 100MB size 2.3. somepath/yyyyMMdd.log:100m:append for the disk file max 100MB size and append mode

func (*QueueWriter) Close

func (p *QueueWriter) Close() error

func (*QueueWriter) Send

func (p *QueueWriter) Send(msg string, countDiscards bool)

Jump to

Keyboard shortcuts

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