rollingwriter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeRollingPerDayFormat    = "2006-01-02"
	DefaultTimeRollingPerHourFormat   = "2006-01-02-15"
	DefaultTimeRollingPerMinuteFormat = "2006-01-02-15_04"
	DefaultTimeRollingPerSecondFormat = "2006-01-02-15_04_05"
)
View Source
const (
	DefaultTimeFormat = `2006-01-02T15-04-05.000`
)

Variables

View Source
var DefaultTimeRollingNamer = TimeRollingNamerFunc(func(filename string, timeformat string, now time.Time) string {
	return fmt.Sprintf("%s.%s", filename, now.Format(timeformat))
})

Functions

This section is empty.

Types

type Clocker

type Clocker interface {
	Now() time.Time
}

type FakeClocker

type FakeClocker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*FakeClocker) Now

func (f *FakeClocker) Now() time.Time

func (*FakeClocker) SetNow

func (f *FakeClocker) SetNow(n time.Time)

type FileRotateWriter

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

func NewFileRotateWriter

func NewFileRotateWriter(filename string) (*FileRotateWriter, error)

func (*FileRotateWriter) Close

func (w *FileRotateWriter) Close() error

func (*FileRotateWriter) Rotate

func (w *FileRotateWriter) Rotate(filename, rotatename string) error

func (*FileRotateWriter) Write

func (w *FileRotateWriter) Write(p []byte) (int, error)

type Option

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

func NewOption

func NewOption() *Option

func (*Option) EnableCompress

func (o *Option) EnableCompress() *Option

func (*Option) EnableLocalTime

func (o *Option) EnableLocalTime() *Option

func (*Option) SetMaxAge

func (o *Option) SetMaxAge(i int) *Option

func (*Option) SetMaxBackups

func (o *Option) SetMaxBackups(i int) *Option

func (*Option) SetMaxSize

func (o *Option) SetMaxSize(i int) *Option

type RollingWriter

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

func New

func New(filename string, option *Option) *RollingWriter

func (*RollingWriter) Close

func (rw *RollingWriter) Close() error

func (*RollingWriter) Write

func (rw *RollingWriter) Write(b []byte) (int, error)

type RotateWriter

type RotateWriter interface {
	io.WriteCloser
	Rotate(name, rotatename string) error
}

type TimeRollingNamer

type TimeRollingNamer interface {
	Name(filename string, timeformat string, now time.Time) string
}

type TimeRollingNamerFunc

type TimeRollingNamerFunc func(filename string, timeformat string, now time.Time) string

func (TimeRollingNamerFunc) Name

func (trn TimeRollingNamerFunc) Name(filename string, timeformat string, now time.Time) string

type TimeRollingWriter

type TimeRollingWriter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTimeRollingWriter

func NewTimeRollingWriter(filename string, option *TimeRollingWriterOption) (*TimeRollingWriter, error)

func (*TimeRollingWriter) Close

func (trw *TimeRollingWriter) Close() error

func (*TimeRollingWriter) Write

func (trw *TimeRollingWriter) Write(p []byte) (int, error)

type TimeRollingWriterOption

type TimeRollingWriterOption struct {
	TimeFormat       string
	Clocker          Clocker
	AppendTimeHeader bool
	RotateWriter     RotateWriter
	TimeRollingNamer TimeRollingNamer
}

type WallClocker

type WallClocker struct {
}

func (WallClocker) Now

func (wc WallClocker) Now() time.Time

Jump to

Keyboard shortcuts

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