file

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package provides a rotating file based on the file size.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSize

func ParseSize(s string) (size int64, err error)

ParseSize parses the size string. The size maybe have a unit suffix, such as "123", "123M, 123G". Valid size units are "b", "B", "k", "K", "m", "M", "g", "G", "t", "T", "p", "P", "e", "E". The lower units are 1000x, and the upper units are 1024x.

Notice: "" will be considered as 0.

Types

type SizedRotatingFile

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

SizedRotatingFile is a file rotating logging writer based on the size.

func NewSizedRotatingFile

func NewSizedRotatingFile(filename string, filesize, filenum int,
	fileperm ...os.FileMode) *SizedRotatingFile

NewSizedRotatingFile returns a new SizedRotatingFile, which is not thread-safe.

Default:

fileperm: 0644
filesize: 100 * 1024 * 1024
filenum:  0

func (*SizedRotatingFile) Close

func (f *SizedRotatingFile) Close() (err error)

Close implements io.Closer.

func (*SizedRotatingFile) Flush

func (f *SizedRotatingFile) Flush() (err error)

Flush flushes the data to the underlying disk.

func (*SizedRotatingFile) Sync

func (f *SizedRotatingFile) Sync() (err error)

Sync is equal to Flush to flush the data to the underlying disk.

func (*SizedRotatingFile) Write

func (f *SizedRotatingFile) Write(data []byte) (n int, err error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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