Help us shape the future of Go! Take the 2026 Go Developer Survey

logrotate

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

logrotate file

GoDoc

This is a fork of https://github.com/nytimes/logrotate to fix casing issues

logrotated can be configured to send a SIGHUP signal to a process after rotating it's logs. This library reopens the underlying os.File when a SIGHUP is received by the app.

Example

This is will enable all log calls to output to the log file without interruption when logrotated rotates the file.

logfile, err := logrotate.NewFile("/log/path/here")
if err != nil {
	log.Fatal(err)
}

log.SetOutput(logfile)

ref: http://linux.die.net/man/8/logrotate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File wraps an *os.File and listens for a 'SIGHUP' signal from logrotated so it can reopen the new file.

func NewFile

func NewFile(path string) (*File, error)

NewFile creates a File pointer and kicks off the goroutine listening for SIGHUP signals.

func (*File) Close

func (lr *File) Close() error

Close will stop the goroutine listening for SIGHUP signals and then close the underlying os.File.

func (*File) Write

func (lr *File) Write(b []byte) (int, error)

Write will write to the underlying file. It uses a sync.Mutex to ensure uninterrupted writes during logrotates.

Jump to

Keyboard shortcuts

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