Discover Packages
github.com/NYTimes/logrotate
package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Feb 12, 2019
License: Apache-2.0
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 56
Opens a new window with list of known importers.
README
README
¶
#logrotate file
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
Expand ▾
Collapse ▴
Documentation
¶
File wraps an *os.File and listens for a 'SIGHUP' signal from logrotated
so it can reopen the new file.
NewFile creates a File pointer and kicks off the goroutine listening for
SIGHUP signals.
Close will stop the goroutine listening for SIGHUP signals and then close
the underlying os.File.
Write will write to the underlying file. It uses a sync.Mutex to ensure
uninterrupted writes during logrotates.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.