writer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

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

FileWriter is a LogWriter which write logs to file

func NewDefaultFileWriter

func NewDefaultFileWriter(filename string) *FileWriter

NewDefaultFileWriter create new single file writer with default file mode and flags

func NewFileWriter

func NewFileWriter(filename string, flag int, perm os.FileMode) *FileWriter

NewFileWriter create a FileWriter

func (*FileWriter) Close

func (writer *FileWriter) Close() error

Close a log file

func (*FileWriter) GetFileStat

func (writer *FileWriter) GetFileStat() (os.FileInfo, error)

func (*FileWriter) GetFilename

func (writer *FileWriter) GetFilename() string

func (*FileWriter) ReOpen

func (writer *FileWriter) ReOpen() error

ReOpen reopen a log file

func (*FileWriter) Write

func (writer *FileWriter) Write(le level.Level, module string, message string) error

Write the message to file

type RotatingFileFn

type RotatingFileFn func(le level.Level, module string) string

type RotatingFileWriter

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

func NewDefaultRotatingFileWriter

func NewDefaultRotatingFileWriter(ctx context.Context, fn RotatingFileFn) *RotatingFileWriter

func NewRotatingFileWriter

func NewRotatingFileWriter(ctx context.Context, gcDuration time.Duration, flag int, perm os.FileMode, fn RotatingFileFn) *RotatingFileWriter

func (*RotatingFileWriter) Close

func (writer *RotatingFileWriter) Close() error

func (*RotatingFileWriter) GC

func (writer *RotatingFileWriter) GC(inactiveDuration time.Duration)

func (*RotatingFileWriter) GetOpenedFiles

func (writer *RotatingFileWriter) GetOpenedFiles() []string

func (*RotatingFileWriter) ReOpen

func (writer *RotatingFileWriter) ReOpen() error

func (*RotatingFileWriter) Write

func (writer *RotatingFileWriter) Write(le level.Level, module string, message string) error

type StackMatchFn

type StackMatchFn func(le level.Level, module string, message string) bool

type StackWriter

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

func NewStackWriter

func NewStackWriter() *StackWriter

NewStackWriter create a new stack writer

func (*StackWriter) Close

func (writer *StackWriter) Close() error

func (*StackWriter) Push

func (writer *StackWriter) Push(w Writer, fn StackMatchFn)

Push add a writer to stacks

func (*StackWriter) PushWithLevels

func (writer *StackWriter) PushWithLevels(w Writer, levels ...level.Level)

PushWithLevels add a writer with only specified levels enabled if no levels specified, we will use all

func (*StackWriter) ReOpen

func (writer *StackWriter) ReOpen() error

func (*StackWriter) Write

func (writer *StackWriter) Write(le level.Level, module string, message string) error

type StreamWriter

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

func NewStdoutWriter

func NewStdoutWriter() *StreamWriter

func NewStreamWriter

func NewStreamWriter(w io.Writer) *StreamWriter

func (*StreamWriter) Close

func (writer *StreamWriter) Close() error

func (*StreamWriter) ReOpen

func (writer *StreamWriter) ReOpen() error

func (*StreamWriter) Write

func (writer *StreamWriter) Write(le level.Level, module string, message string) error

type SyslogWriter

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

SyslogWriter is a log writer for syslog

func NewSyslogWriter

func NewSyslogWriter(network, raddr string, priority syslog.Priority, tag string) *SyslogWriter

NewSyslogWriter create a new SyslogWriter

func (*SyslogWriter) Close

func (w *SyslogWriter) Close() error

func (*SyslogWriter) ReOpen

func (w *SyslogWriter) ReOpen() error

func (*SyslogWriter) Write

func (w *SyslogWriter) Write(le level.Level, module string, message string) error

type Writer

type Writer interface {
	Write(le level.Level, module string, message string) error
	ReOpen() error
	Close() error
}

Writer 日志输出接口

Jump to

Keyboard shortcuts

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