writerpkg

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DefaultRotationTime       = time.Hour * 24      // 1天
	DefaultRotationSize       = 50 << 20            // 50M
	DefaultRotationStorageAge = time.Hour * 24 * 30 // 30天
	DefaultRotationCounter    = 10086               // 10086个

)

轮转日志参数

Variables

This section is empty.

Functions

func NewDummyWriter

func NewDummyWriter() (io.Writer, error)

NewDummyWriter 假的

func NewRotateFile

func NewRotateFile(cfg *ConfigRotate, configOpts ...Option) (writer io.Writer, err error)

NewRotateFile 轮转输出

Types

type ConfigRotate

type ConfigRotate struct {
	// 存储位置
	// Dir 文件夹
	Dir string
	// Filename 文件名(默认:${filename}_app.%Y%m%d.log)
	Filename string

	// RotateTime 轮询规则:n久(默认:86400s # 86400s = 1天)
	// 轮询规则:默认为:RotateTime
	RotateTime time.Duration
	// RotateSize 轮询规则:按文件大小RotateSize(默认:52428800 # 50<<20 = 50M)
	// 轮询规则:默认为:RotateTime
	RotateSize int64

	// StorageAge 存储规则:n久(默认:30天)
	// 存储规则:默认为:StorageAge
	StorageAge time.Duration
	// StorageCounter 存储规则:n个(默认:10086个)
	// 存储规则:默认为:StorageAge
	StorageCounter uint
}

ConfigRotate 轮转输出

type Option

type Option func(*options)

Option is config option.

func WithFilenameSuffix

func WithFilenameSuffix(suffix string) Option

WithFilenameSuffix 文件名后缀

Jump to

Keyboard shortcuts

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