logstream

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package logstream is used to buffer and write logs to a log stream server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogBuffer

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

LogBuffer stores logs in a file and limits the amount of logs written

func NewLogBuffer

func NewLogBuffer() (*LogBuffer, error)

NewLogBuffer returns a new LogBuffer

func (*LogBuffer) Bytes

func (b *LogBuffer) Bytes(offset, n int32) ([]byte, error)

Bytes returns a chunk of bytes from the log file

func (*LogBuffer) Checksum

func (b *LogBuffer) Checksum() string

Checksum returns the checksum for the log data

func (*LogBuffer) Close

func (b *LogBuffer) Close()

Close removes the underlying log file

func (*LogBuffer) SetLimit

func (b *LogBuffer) SetLimit(size int)

SetLimit sets the limit for log data in bytes

func (*LogBuffer) Size

func (b *LogBuffer) Size() int32

Size returns the number of bytes written

func (*LogBuffer) Write

func (b *LogBuffer) Write(p []byte) (int, error)

type LogSink

type LogSink interface {
	Write(ctx context.Context, startOffset int32, buffer []byte) error
}

LogSink represents a sink for writing logs to

type Writer

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

Writer is responsible for buffering and writing logs to the specified log sink

func NewWriter

func NewWriter(sink LogSink, logger logger.Logger) (*Writer, error)

NewWriter returns a new writer instance

func (*Writer) Close

func (j *Writer) Close()

Close flushes the logger

func (*Writer) Flush

func (j *Writer) Flush()

Flush will attempt to send all logs currently stored in the buffer

func (*Writer) Start

func (j *Writer) Start()

Start will start the goroutine which sends logs to the log sink

func (*Writer) Write

func (j *Writer) Write(data []byte) (n int, err error)

Write will append the data to the log buffer

Jump to

Keyboard shortcuts

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