Movatterモバイル変換


[0]ホーム

URL:


loggerutils

package
v28.5.2+incompatibleLatest Latest
Warning

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

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

Details

Repository

github.com/moby/moby

Links

Documentation

Index

Constants

View Source
const DefaultTemplate = "{{.ID}}"

DefaultTemplate defines the defaults template logger should use.

Variables

View Source
var ErrQueueClosed =errors.New("queue is closed")

Functions

funcParseLogTag

func ParseLogTag(infologger.Info, defaultTemplatestring) (string,error)

ParseLogTag generates a context aware tag for consistency across differentlog drivers based on the context of the running container.

Types

typeDecoder

type Decoder interface {// Reset resets the decoder// Reset is called for certain events, such as log rotationsReset(io.Reader)// Decode decodes the next log message from the streamDecode() (*logger.Message,error)// Close signals to the decoder that it can release whatever resources it was using.Close()}

Decoder is for reading logsIt is created by the log reader by calling the `MakeDecoderFunc`

typeGetTailReaderFunc

type GetTailReaderFunc func(ctxcontext.Context, fSizeReaderAt, nLogLinesint) (rdrSizeReaderAt, nLinesint, errerror)

GetTailReaderFunc is used to truncate a reader to only read as much as is requiredin order to get the passed in number of log lines.It returns the sectioned reader, the number of lines that the section readercontains, and any error that occurs.

typeLogFile

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

LogFile is Logger implementation for default Docker logging.

funcNewLogFile

func NewLogFile(logPathstring, capacityint64, maxFilesint, compressbool, decodeFuncMakeDecoderFn, permsos.FileMode, getTailReaderGetTailReaderFunc) (*LogFile,error)

NewLogFile creates new LogFile

func (*LogFile)Close

func (w *LogFile) Close()error

Close closes underlying file and signals all readers to stop.

func (*LogFile)MaxFiles

func (w *LogFile) MaxFiles()int

MaxFiles return maximum number of files

func (*LogFile)ReadLogs

func (w *LogFile) ReadLogs(ctxcontext.Context, configlogger.ReadConfig) *logger.LogWatcher

ReadLogs decodes entries from log files.

It is the caller's responsibility to call ConsumerGone on the LogWatcher.

func (*LogFile)WriteLogEntry

func (w *LogFile) WriteLogEntry(timestamptime.Time, marshalled []byte)error

WriteLogEntry writes the provided log message to the current log file.This may trigger a rotation event if the max file/capacity limits are hit.

typeMakeDecoderFn

type MakeDecoderFn func(rdrio.Reader)Decoder

MakeDecoderFn creates a decoder

typeMessageQueue

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

MessageQueue is a queue for log messages.

MessageQueue.Enqueue will block when the queue is full.To dequeue messages callMessageQueue.Receiver and pull messages off thereturned channel.

Closing only prevents new messages from being added to the queue.The queue can still be drained after close.

The zero value of MessageQueue is safe to use, but does not do any internalbuffering (queue size is 0).

funcNewMessageQueue

func NewMessageQueue(maxSizeint) *MessageQueue

NewMessageQueue creates a new queue with the specified size.

func (*MessageQueue)Close

func (q *MessageQueue) Close()

Close prevents any new messages from being added to the queue.

func (*MessageQueue)Enqueue

func (q *MessageQueue) Enqueue(ctxcontext.Context, m *logger.Message)error

Enqueue adds the provided message to the queue.Enqueue blocks if the queue is full.

The two possible error cases are:1. The provided context is cancelled2.ErrQueueClosed when the queue has been closed.

func (*MessageQueue)Receiver

func (q *MessageQueue) Receiver() <-chan *logger.Message

Receiver returns a channel that can be used to dequeue messagesThe channel will be closed when the message queue is closed but may havemessages buffered.

typeSizeReaderAt

type SizeReaderAt interface {io.Readerio.ReaderAtSize()int64}

SizeReaderAt defines a ReaderAt that also reports its size.This is used for tailing log files.

Source Files

View all Source files

Directories

PathSynopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp