Documentation ¶
Overview ¶
Package rotation provides file rotation when files hit a given size.
Index ¶
- Constants
- Variables
- func DefaultPath() string
- func MaxBackups(maxBackups int) func(*Rotator) error
- func MaxSize(maxSize int64) func(*Rotator) error
- func ParseAndSetupLogging(cl *cmdline.CmdLine, consoleOnByDefault bool) []string
- func Path(path string) func(*Rotator) error
- func WithMask(mask os.FileMode) func(*Rotator) error
- type Rotator
Constants ¶
const ( DefaultMaxSize = 10 * 1024 * 1024 DefaultMaxBackups = 1 )
Constants for defaults.
Variables ¶
var PathToLog string
PathToLog holds the path to the log file that was configured on the command line when using ParseAndSetup().
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the default path that will be used. This will use cmdline.AppIdentifier (if set) to better isolate the log location.
func MaxBackups ¶
MaxBackups sets the maximum number of old log files to retain. Defaults to DefaultMaxBackups.
func MaxSize ¶
MaxSize sets the maximum size of the log file before it gets rotated. Defaults to DefaultMaxSize.
func ParseAndSetupLogging ¶ added in v1.96.0
ParseAndSetupLogging adds command-line options for controlling logging, parses the command line, then instantiates a rotator and attaches it to slog. Returns the remaining arguments that weren't used for option content. If consoleOnByDefault is true, then logs will also go to the console by default, but an option to turn them off will be added to the command line flags. Conversely, if it is false, an option to turn them on will be added to the command line flags.
Types ¶
type Rotator ¶
type Rotator struct {
// contains filtered or unexported fields
}
Rotator holds the rotator data.
func (*Rotator) PathToLog ¶ added in v1.75.0
PathToLog returns the path to the log file that will be used.