package loggerutils
import "github.com/docker/docker/daemon/logger/loggerutils"
Index ¶
- Constants
- Variables
- func ParseLogTag(info logger.Info, defaultTemplate string) (string, error)
- type Decoder
- type GetTailReaderFunc
- type LogFile
- func NewLogFile(logPath string, capacity int64, maxFiles int, compress bool, decodeFunc MakeDecoderFn, perms os.FileMode, getTailReader GetTailReaderFunc) (*LogFile, error)
- func (w *LogFile) Close() error
- func (w *LogFile) MaxFiles() int
- func (w *LogFile) ReadLogs(ctx context.Context, config logger.ReadConfig) *logger.LogWatcher
- func (w *LogFile) WriteLogEntry(timestamp time.Time, marshalled []byte) error
- type MakeDecoderFn
- type MessageQueue
- func NewMessageQueue(maxSize int) *MessageQueue
- func (q *MessageQueue) Close()
- func (q *MessageQueue) Enqueue(ctx context.Context, m *logger.Message) error
- func (q *MessageQueue) Receiver() <-chan *logger.Message
- type SizeReaderAt
Constants ¶
const DefaultTemplate = "{{.ID}}"
DefaultTemplate defines the defaults template logger should use.
Variables ¶
Functions ¶
func ParseLogTag ¶
ParseLogTag generates a context aware tag for consistency across different log drivers based on the context of the running container.
Types ¶
type Decoder ¶
type Decoder interface { // Reset resets the decoder // Reset is called for certain events, such as log rotations Reset(io.Reader) // Decode decodes the next log message from the stream Decode() (*logger.Message, error) // Close signals to the decoder that it can release whatever resources it was using. Close() }
Decoder is for reading logs It is created by the log reader by calling the `MakeDecoderFunc`
type GetTailReaderFunc ¶
type GetTailReaderFunc func(ctx context.Context, f SizeReaderAt, nLogLines int) (rdr SizeReaderAt, nLines int, err error)
GetTailReaderFunc is used to truncate a reader to only read as much as is required in order to get the passed in number of log lines. It returns the sectioned reader, the number of lines that the section reader contains, and any error that occurs.
type LogFile ¶
type LogFile struct {
// contains filtered or unexported fields
}
LogFile is Logger implementation for default Docker logging.
func NewLogFile ¶
func NewLogFile(logPath string, capacity int64, maxFiles int, compress bool, decodeFunc MakeDecoderFn, perms os.FileMode, getTailReader GetTailReaderFunc) (*LogFile, error)
NewLogFile creates new LogFile
func (*LogFile) Close ¶
Close closes underlying file and signals all readers to stop.
func (*LogFile) MaxFiles ¶
MaxFiles return maximum number of files
func (*LogFile) ReadLogs ¶
func (w *LogFile) ReadLogs(ctx context.Context, config logger.ReadConfig) *logger.LogWatcher
ReadLogs decodes entries from log files.
It is the caller's responsibility to call ConsumerGone on the LogWatcher.
func (*LogFile) WriteLogEntry ¶
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.
type MakeDecoderFn ¶
MakeDecoderFn creates a decoder
type MessageQueue ¶
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 call MessageQueue.Receiver and pull messages off the returned 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 internal buffering (queue size is 0).
func NewMessageQueue ¶
func NewMessageQueue(maxSize int) *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 ¶
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 cancelled 2. 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 messages The channel will be closed when the message queue is closed but may have messages buffered.
type SizeReaderAt ¶
SizeReaderAt defines a ReaderAt that also reports its size. This is used for tailing log files.
Source Files ¶
file_unix.go follow.go log_tag.go logfile.go queue.go sharedtemp.go
Directories ¶
Path | Synopsis |
---|---|
daemon/logger/loggerutils/cache |
- Version
- v28.1.1+incompatible (latest)
- Published
- Apr 18, 2025
- Platform
- js/wasm
- Imports
- 21 packages
- Last checked
- 6 hours ago –
Tools for package owners.