zaproll

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

zaproll provides a rolling logger for nanozap.

zaproll use buffer writer to improve I/O throughput, and there is only one goroutine could write, so Mutex is light.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

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

Backup holds backup log file' path & create time.

type Backups

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

Backups implements heap interface.

func (*Backups) Len

func (b *Backups) Len() int

func (*Backups) Less

func (b *Backups) Less(i, j int) bool

func (*Backups) Pop

func (b *Backups) Pop() (v interface{})

func (*Backups) Push

func (b *Backups) Push(v interface{})

func (*Backups) Swap

func (b *Backups) Swap(i, j int)

type Config

type Config struct {
	// OutputPath is the log file path.
	OutputPath string `json:"output_path" toml:"output_path"`
	// MaxSize is the maximum size of a log file before it gets rotated.
	// Unit: MB.
	// Default: 128 (128MB).
	MaxSize int64 `json:"max_size_mb" toml:"max_size_mb"`
	// MaxBackups is the maximum number of backup log files to retain.
	MaxBackups int `json:"max_backups" toml:"max_backups"`
	// LocalTime is the timestamp in backup log file. Default is to use UTC time.
	// If true, use local time.
	LocalTime bool `json:"local_time" toml:"local_time"`

	// PerWriteSize is zaproll's write size,
	// zaproll writes data to page cache every PerWriteSize.
	// Unit: KB.
	// Default: 64 (64KB).
	//
	// It's used for combining writes.
	// The size of it should be aligned to page size,
	// and it shouldn't be too large, because that may block zaproll write.
	PerWriteSize int64 `json:"per_write_size" toml:"per_write_size"`
	// PerSyncSize is zaproll's sync size,
	// zaproll flushes data to storage media(hint) every PerSyncSize.
	// Unit: MB.
	// Default: 16 (16MB).
	//
	// The size of it should be aligned to page size,
	// and it shouldn't be too large, avoiding burst I/O.
	PerSyncSize int64 `json:"per_sync_size" toml:"per_sync_size"`

	// Develop mode. Default is false.
	// It' used for testing, if it's true, the page cache control unit could not be aligned to page cache size.
	Developed bool `json:"developed" toml:"developed"`
}

Config of zaproll.

type Rotation

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

Rotation is implement io.WriteCloser interface with func Sync() (err error).

func New

func New(cfg *Config) (r *Rotation, err error)

New creates a Rotation.

func (*Rotation) Close

func (r *Rotation) Close() (err error)

Close closes Rotation and release all resources.

func (*Rotation) Sync

func (r *Rotation) Sync() (err error)

Sync syncs all dirty data.

func (*Rotation) Write

func (r *Rotation) Write(p []byte) (written int, err error)

Write writes data to buffer then notify file write.

Jump to

Keyboard shortcuts

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