loggers

package
v0.0.0-...-5348dab Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUndefined tells the caller that the logger they tried to log to is not defined
	ErrUndefined = errors.New("Logger not defined")
)

Functions

This section is empty.

Types

type DummyNotifierHarness

type DummyNotifierHarness struct {
}

DummyNotifierHarness is a struct that implements the uploader.NotifierHarness and uploader.NotifierHarness with nop implementations.

It exists because the code that uses the Harnesses doesn't accept nil for cases where we do not want to notify at all.

func (*DummyNotifierHarness) SendError

func (d *DummyNotifierHarness) SendError(error)

SendError - nop implementation

func (*DummyNotifierHarness) SendMessage

func (d *DummyNotifierHarness) SendMessage(r *uploader.UploadReceipt) error

SendMessage - nop implementation

type EventToStringFunc

type EventToStringFunc func(*spade.Event) (string, error)

An EventToStringFunc takes a spade event and converts it to a string for logging into a line oriented file on s3

type KinesisLoggerConfig

type KinesisLoggerConfig struct {
	// StreamName is the name of the Kinesis stream we are producing events into
	StreamName string

	// BatchLength is the max amount of globs per batch sent to Kinesis
	BatchLength int

	// BatchSize is the max size in bytes per batch sent to Kinesis
	BatchSize int

	// BatchAge is the max age of the oldest glob in the batch
	BatchAge string

	// GlobLength is the max amount of events per glob
	GlobLength int

	// GlobSize is the max size in bytes per glob
	GlobSize int

	// GlobAge is the max age of the oldest record in the glob
	GlobAge string

	// BufferLength is the length of the buffer in front of the kinesis production code. If the buffer fills
	// up events will be written to the fallback logger
	BufferLength uint

	// MaxAttemptsPerRecord is the maximum amounts an event will be resent to Kinesis on failure
	// before it is written to the fallback logger
	MaxAttemptsPerRecord int

	// RetryDelay is how long to delay between retries on failed attempts to write to kinesis
	RetryDelay string
}

KinesisLoggerConfig is used to configure a new SpadeEdgeLogger that writes to an AWS Kinesis stream. There are no default values and all fields are required.

func (*KinesisLoggerConfig) Validate

func (c *KinesisLoggerConfig) Validate() error

Validate verifies that a KinesisLoggerConfig is valid, and updates any internal members

type S3LoggerConfig

type S3LoggerConfig struct {
	Bucket   string
	MaxLines int
	MaxAge   string
}

S3LoggerConfig configures a new SpadeEdgeLogger that writes lines of text to AWS S3

type SpadeEdgeLogger

type SpadeEdgeLogger interface {
	Log(event *spade.Event) error
	Close()
}

A SpadeEdgeLogger stores events that are received at the spade edge

func NewKinesisLogger

func NewKinesisLogger(client *kinesis.Kinesis, config KinesisLoggerConfig, fallback SpadeEdgeLogger, statter statsd.Statter) (SpadeEdgeLogger, error)

NewKinesisLogger creates a new SpadeEdgeLogger that writes to an AWS Kinesis stream and starts the main loop

func NewS3Logger

func NewS3Logger(
	config S3LoggerConfig,
	loggingDir string,
	printFunc EventToStringFunc,
	sqs sqsiface.SQSAPI,
	S3Uploader s3manageriface.UploaderAPI,
) (SpadeEdgeLogger, error)

NewS3Logger returns a new SpadeEdgeLogger that events to S3 after transforming the events into lines of text using the printFunc

type UndefinedLogger

type UndefinedLogger struct {
}

UndefinedLogger is a struct that implements the SpadeEdgeLogger interface with nop implementations

func (UndefinedLogger) Close

func (UndefinedLogger) Close()

Close doesn't have anything to do

func (UndefinedLogger) Log

func (UndefinedLogger) Log(event *spade.Event) error

Log is a nop implementation

Jump to

Keyboard shortcuts

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