file

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "file"

Variables

View Source
var (
	LineEnding = []byte("\n")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// WorkerCount is the number of concurrent goroutines writing files
	WorkerCount int `yaml:"workerCount,omitempty" default:"1"`
	// BaseDirs is a collection of directories that specify which directories to
	// write to, usually used when mounting a disk, and can be empty
	BaseDirs []string `yaml:"baseDirs,omitempty"`
	// DirHashKey
	DirHashKey string `yaml:"dirHashKey,omitempty"`
	// Filename is the file to write logs to.  Backup log files will be retained
	// in the same directory.
	Filename string `yaml:"filename,omitempty" validate:"required"`
	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int `yaml:"maxSize,omitempty" default:"100"`
	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int `yaml:"maxAge,omitempty"`
	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int `yaml:"maxBackups,omitempty"`
	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time.  The default is to use UTC
	// time.
	LocalTime bool `yaml:"localTime,omitempty"`

	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `yaml:"compress,omitempty"`
}

func (*Config) Validate added in v1.2.0

func (c *Config) Validate() error

type Message

type Message struct {
	Filename string
	Data     []byte
}

type MultiFileWriter

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

func NewMultiFileWriter

func NewMultiFileWriter(opt *Options) (*MultiFileWriter, error)

func (*MultiFileWriter) Close

func (w *MultiFileWriter) Close() error

func (*MultiFileWriter) Write

func (w *MultiFileWriter) Write(msgs ...Message) error

type Options

type Options struct {
	WorkerCount int
	MaxSize     int
	MaxAge      int
	MaxBackups  int
	LocalTime   bool
	Compress    bool
	IdleTimeout time.Duration
}

type Sink

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

func NewSink

func NewSink() *Sink

func (*Sink) Category

func (s *Sink) Category() api.Category

func (*Sink) Config

func (s *Sink) Config() interface{}

func (*Sink) Consume

func (s *Sink) Consume(batch api.Batch) api.Result

func (*Sink) Init

func (s *Sink) Init(context api.Context) error

func (*Sink) SetCodec

func (s *Sink) SetCodec(c codec.Codec)

func (*Sink) Start

func (s *Sink) Start() error

func (*Sink) Stop

func (s *Sink) Stop()

func (*Sink) String

func (s *Sink) String() string

func (*Sink) Type

func (s *Sink) Type() api.Type

type Writer

type Writer struct {
	// This field is required.
	W io.Writer

	// Size specifies the maximum amount of data the writer will buffered
	// before flushing.
	//
	// Defaults to 256 kB if unspecified.
	Size int

	// AutoFlushDisabled whether to disable automatic flush
	AutoFlushDisabled bool
	// FlushInterval specifies how often the writer should flush data if
	// there have been no writes.
	//
	// Defaults to 30 seconds if unspecified.
	FlushInterval time.Duration
	// contains filtered or unexported fields
}

func (*Writer) Stop

func (w *Writer) Stop() (err error)

Stop closes the buffer, cleans up background goroutines, and flushes remaining unwritten data.

func (*Writer) Sync

func (w *Writer) Sync() error

Sync flushes buffered log data into disk directly.

func (*Writer) Write

func (w *Writer) Write(bs []byte) (int, error)

Write writes log data into buffer syncer directly, multiple Write calls will be batched, and log data will be flushed to disk when the buffer is full or periodically.

Jump to

Keyboard shortcuts

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