slogger: github.com/mongodb/slogger/v2/slogger/rolling_file_appender Index | Files

package rolling_file_appender

import "github.com/mongodb/slogger/v2/slogger/rolling_file_appender"

Index

Package Files

error.go hidden_unix.go rolling_file_appender.go rotation_time.go state.go

Constants

const MAX_ROTATE_SERIAL_NUM = 1000000000

func IsCloseError Uses

func IsCloseError(err error) bool

func IsDecodeError Uses

func IsDecodeError(err error) bool

func IsEncodeError Uses

func IsEncodeError(err error) bool

func IsMinorRotationError Uses

func IsMinorRotationError(err error) bool

func IsNoFileError Uses

func IsNoFileError(err error) bool

func IsOpenError Uses

func IsOpenError(err error) bool

func IsRenameError Uses

func IsRenameError(err error) bool

func IsStatError Uses

func IsStatError(err error) bool

func IsSyncError Uses

func IsSyncError(err error) bool

func IsWriteError Uses

func IsWriteError(err error) bool

type CloseError Uses

type CloseError struct {
    Filename string
    Err      error
}

func (CloseError) Error Uses

func (self CloseError) Error() string

type DecodeError Uses

type DecodeError struct {
    Filename string
    Err      error
}

func (DecodeError) Error Uses

func (self DecodeError) Error() string

type EncodeError Uses

type EncodeError struct {
    Filename string
    Err      error
}

func (EncodeError) Error Uses

func (self EncodeError) Error() string

type MinorRotationError Uses

type MinorRotationError struct {
    Err error
}

func (MinorRotationError) Error Uses

func (self MinorRotationError) Error() string

type NoFileError Uses

type NoFileError struct{}

func (NoFileError) Error Uses

func (NoFileError) Error() string

type OpenError Uses

type OpenError struct {
    Filename string
    Err      error
}

func (OpenError) Error Uses

func (self OpenError) Error() string

type RenameError Uses

type RenameError struct {
    OldFilename string
    NewFilename string
    Err         error
}

func (RenameError) Error Uses

func (self RenameError) Error() string

type RollingFileAppender Uses

type RollingFileAppender struct {
    // contains filtered or unexported fields
}

func New Uses

func New(filename string, maxFileSize int64, maxDuration time.Duration, maxRotatedLogs int, rotateIfExists bool, headerGenerator func() []string) (*RollingFileAppender, error)

New creates a new RollingFileAppender.

filename is path to the file to log to. It can be a relative path (with respect to the current working directory) or an absolute path.

maxFileSize is the approximate file size that will be allowed before the log file is rotated. Rotated log files will have suffix of the form .YYYY-MM-DDTHH-MM-SS or .YYYY-MM-DDTHH-MM-SS-N (where N is an incrementing serial number used to resolve conflicts) appended to them. Set maxFileSize to a non-positive number if you wish there to be no limit.

maxDuration is how long to wait before rotating the log file. Set to 0 if you do not want log rotation to be time-based.

If both maxFileSize and maxDuration are set than the log file will be rotated whenever either threshold is met. The duration used to determine whether a log file should be rotated (that is, the duration compared to maxDuration) is reset regardless of why the log was rotated previously.

maxRotatedLogs specifies the maximum number of rotated logs allowed before old logs are deleted. Set to a non-positive number if you do not want old log files to be deleted.

If rotateIfExists is set to true and a log file with the same filename already exists, then the current one will be rotated. If rotateIfExists is set to false and a log file with the same filename already exists, then the current log file will be appended to. If a log file with the same filename does not exist, then a new log file is created regardless of the value of rotateIfExists.

As RotatingFileAppender might be wrapped by an AsyncAppender, an errHandler can be provided that will be called when an error occurs. It can set to nil if you do not want to provide one.

The return value headerGenerator, if not nil, is logged at the beginning of every log file.

Note that after creating a RollingFileAppender with New(), you will probably want to defer a call to RollingFileAppender's Close() (or at least Flush()). This ensures that in case of program exit (normal or panicking) that any pending logs are logged.

func NewWithStringWriter Uses

func NewWithStringWriter(filename string, maxFileSize int64, maxDuration time.Duration, maxRotatedLogs int, rotateIfExists bool, headerGenerator func() []string, stringWriterCallback func(*os.File) slogger.StringWriter) (*RollingFileAppender, error)

func (*RollingFileAppender) Append Uses

func (self *RollingFileAppender) Append(log *slogger.Log) error

func (*RollingFileAppender) Close Uses

func (self *RollingFileAppender) Close() error

func (*RollingFileAppender) Flush Uses

func (self *RollingFileAppender) Flush() error

func (*RollingFileAppender) Reopen Uses

func (self *RollingFileAppender) Reopen() error

Useful for manual log rotation. For example, logrotated may rename the log file and then ask us to reopen it. Before reopening it we will be writing to the renamed log file. After reopening we will be writing to a new log file with the original name.

func (*RollingFileAppender) Rotate Uses

func (self *RollingFileAppender) Rotate() error

type RotationTime Uses

type RotationTime struct {
    Time     time.Time
    Serial   int
    Filename string
}

type RotationTimeSlice Uses

type RotationTimeSlice [](*RotationTime)

func (RotationTimeSlice) Len Uses

func (self RotationTimeSlice) Len() int

func (RotationTimeSlice) Less Uses

func (self RotationTimeSlice) Less(i, j int) bool

func (RotationTimeSlice) Swap Uses

func (self RotationTimeSlice) Swap(i, j int)

type StatError Uses

type StatError struct {
    Filename string
    Err      error
}

func (StatError) Error Uses

func (self StatError) Error() string

type SyncError Uses

type SyncError struct {
    Filename string
    Err      error
}

func (SyncError) Error Uses

func (self SyncError) Error() string

type WriteError Uses

type WriteError struct {
    Filename string
    Err      error
}

func (WriteError) Error Uses

func (self WriteError) Error() string

Package rolling_file_appender imports 10 packages (graph). Updated 2016-12-18. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).