tasklogger

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FlushInterval is the longest time that the logger will buffer logs in memory before
	// flushing them to the database. This is set low to ensure a good user experience.
	FlushInterval = 20 * time.Millisecond
	// BufferSize is the largest number of logs lines that can be buffered before flushing them to
	// the database. For the strategy of many-rows-per-insert, performance was significantly worse
	// below 500, and no improvements after 1000.
	BufferSize = 1000
)

Functions

func CreateLogFromMaster

func CreateLogFromMaster(taskID model.TaskID, level, log string) *model.TaskLog

CreateLogFromMaster creates a tasklog of the format that we expect when it comes from master.

func Insert

func Insert(l *model.TaskLog)

Insert a log with the default task logger.

func SetDefaultLogger

func SetDefaultLogger(l *Logger)

SetDefaultLogger sets the task.Logger singleton used by package-level functions.

Types

type Logger

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

Logger is an abstraction for inserting master-side inserted task logs, such as scheduling and provisioning information, or container exit statuses. TODO(DET-9537): Add graceful shutdown for the tasklogger, so that when we intentionally blip the master for something like a configuration update we do not lose logs.

func New

func New(backend Writer) *Logger

New creates an logger which can buffer up task logs and flush them periodically. There should only be one logger shared across the entire system.

func (*Logger) Insert

func (l *Logger) Insert(tl *model.TaskLog)

Insert a log into the buffer to be flush within some interval.

type Writer

type Writer interface {
	AddTaskLogs([]*model.TaskLog) error
}

Writer stores task logs in a backend.

Jump to

Keyboard shortcuts

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