introtator

package
v0.0.0-...-cb73b9c Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package introtator provides an interface for Rotatorr that renames backup log files with an incrementing integer in the name. By default rotated log files are named: service.1.log.

Control the order of integers with Layout.FileOrder.

In Ascending mode, the current file is always rotated to `.1`, and all the files in the way are rotated first. In Descending mode the existing files are pruned, then files are rotated down and lastly the current file is rotated to the next highest integer.

Index

Constants

View Source
const (
	LogExt  = ".log"  // suffixed to an integer.
	LogExt1 = "1.log" // suffixed to the prefix.
	GZext   = ".gz"   // trimmed off found files.
	Joiner  = "."     // joins prefix with integer.
)

Some constant this package uses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

type Layout struct {
	ArchiveDir string // Location where rotated backup logs are moved to.
	FileCount  int    // Maximum number of rotated log files.
	FileOrder  Order  // Control the order of the integer-named backup log files.
	PostRotate func(fileName, newFile string)
	filer.Filer
}

Layout defines how integer-stamped backup logs have their file names decided. This also sets how many files are kept; default is unlimited. Recommend setting FileCount when FileOrder is set to Ascending (default), otherwise the app may spend a lot of time renaming files. If you enable compression with a PostRotate hook, make sure compression finishes before the files are rotated.

func (*Layout) Dirs

func (l *Layout) Dirs(fileName string) ([]string, error)

Dirs checks our config and returns the folder for rotatorr library to create them.

func (*Layout) Post

func (l *Layout) Post(fileName, newFile string)

Post satisfies the Rotatorr interface.

func (*Layout) Rotate

func (l *Layout) Rotate(fileName string) (string, error)

Rotate forces the log to rotate immediately. Returns the new name of the rotated log.

type Order

type Order uint8

Order defines which direction the files are written in.

const (
	Ascending Order = iota
	Descending
)

Ascending order writes files 1-10 in sequence. Descending order writes them 10-1 in sequence.

Jump to

Keyboard shortcuts

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