Documentation ¶
Overview ¶
Package compressor provides a simple interface used for a post-rotate Rotatorr hook that compresses files.
Index ¶
- Constants
- Variables
- func CompressBackground(fileName string, cb func(report *Report))
- func CompressBackgroundPostRotate(_, fileName string)
- func CompressBackgroundWithLog(fileName string, printf func(msg string, fmt ...interface{}))
- func CompressPostRotate(_, fileName string)
- func CompressWithLog(fileName string, printf func(msg string, fmt ...interface{}))
- func Log(report *Report, printf func(msg string, fmt ...interface{}))
- type Report
Constants ¶
const SuffixGZ = ".gz"
SuffixGZ is appended to a fileName to make the new compressed file name.
Variables ¶
var CompressLevel = gzip.DefaultCompression //nolint:gochecknoglobals
CompressLevel sets the global compression level.
var Filer = filer.Default() //nolint:gochecknoglobals
Filer allows overriding os-file procedures.
Functions ¶
func CompressBackground ¶
CompressBackground runs a file compression in the background. A report is sent to a provided callback function when compression finishes. Avoid using this on files that may be renamed by another thread.
func CompressBackgroundPostRotate ¶
func CompressBackgroundPostRotate(_, fileName string)
CompressBackgroundPostRotate satisfies the post-rotate interface in rotatorr. This rotates a file and writes the success to the old log file, or the error to the existing log file (using the global logger). This is safe for use with the timerotator package.
func CompressBackgroundWithLog ¶
CompressBackgroundWithLog like CompressBackground runs a file compression in the background, but writes a log message when finished instead of a callback. Avoid using this on files that may be renamed by another thread.
func CompressPostRotate ¶
func CompressPostRotate(_, fileName string)
CompressPostRotate satisfies the post-rotate interface in rotatorr. This rotates a file and writes the success to the old log file, or the error to the existing log file (using the global logger). This is safe for use with the introtator package.
func CompressWithLog ¶
CompressWithLog is the same as Compress, except it writes a report log instead of returning it.