filerotate

package
Version: v0.0.0-...-f928e5d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

func IsSameHour

func IsSameHour(t1, t2 time.Time) bool

Types

type Config

type Config struct {
	DidClose           func(path string, didRotate bool)
	PathIfShouldRotate func(creationTime time.Time, now time.Time) string
}

type File

type File struct {
	sync.Mutex

	// Path is the path of the current file
	Path string
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*File, error)

func NewDaily

func NewDaily(dir string, didClose func(path string, didRotate bool)) (*File, error)

func NewHourly

func NewHourly(dir string, didClose func(path string, didRotate bool)) (*File, error)

func (*File) Close

func (f *File) Close() error

func (*File) Flush

func (f *File) Flush() error

Flush flushes the file

func (*File) Write

func (f *File) Write(d []byte) (int, error)

Write writes data to a file

func (*File) Write2

func (f *File) Write2(d []byte, flush bool) (string, int64, int, error)

Write2 writes data to a file, optionally flushes. To enable users to later seek to where the data was written, it returns name of the file where data was written, offset at which the data was written, number of bytes and error

Source Files

Jump to

Keyboard shortcuts

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