selfrotate

package
v0.0.0-...-5019c65 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package selfrotate provides zap sync that automatically rotates log files according to provided config.

Index

Constants

View Source
const (
	RotateHourly = RotateInterval(time.Hour)
	RotateDaily  = RotateInterval(time.Hour * 24)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Compress

type Compress int
const (
	// Never compress output files.
	CompressNone Compress = iota

	// Compress file in background after rotation.
	//
	// This policy is useful when used together with default zap core, because log file is guaranteed to be consistent,
	// even if go program crashes in the middle of file operation.
	CompressDelayed

	// Compress output lines before writing them to file.
	//
	// This policy applies gzip compression to each individual buffer passed to Write(). Only useful together with
	// async zap core that does log line batching.
	CompressAtomic
)

type Options

type Options struct {
	// Name is path to first output file.
	Name string

	// MaxKeep is maximal number of log files to keep.
	//
	// If MaxKeep == 0, count based rotation is disabled.
	MaxKeep int

	// MaxSize limits number of log files to keep, based of total file size in bytes.
	//
	// If MaxSize == 0, size based rotation is disabled.
	MaxSize int64

	// MinFreeSpace limits number of log files based of free space available on log file partition.
	MinFreeSpace float64

	// Compress configures log compression policy.
	Compress Compress

	// RotateInterval specifies rotation interval for logs.
	//
	// By default, rotate every hour.
	RotateInterval RotateInterval
}

type RotateInterval

type RotateInterval time.Duration

type Writer

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

func New

func New(options Options) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Sync

func (w *Writer) Sync() error

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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