docker: Index | Files | Directories

package loggerutils

import ""


Package Files

file_unix.go log_tag.go logfile.go


const DefaultTemplate = "{{.ID}}"

DefaultTemplate defines the defaults template logger should use.

func ParseLogTag Uses

func ParseLogTag(info logger.Info, defaultTemplate string) (string, error)

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

type Decoder Uses

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

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

type GetTailReaderFunc Uses

type GetTailReaderFunc func(ctx context.Context, f SizeReaderAt, nLogLines int) (rdr io.Reader, 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 Uses

type LogFile struct {
    // contains filtered or unexported fields

LogFile is Logger implementation for default Docker logging.

func NewLogFile Uses

func NewLogFile(logPath string, capacity int64, maxFiles int, compress bool, marshaller logger.MarshalFunc, decodeFunc MakeDecoderFn, perms os.FileMode, getTailReader GetTailReaderFunc) (*LogFile, error)

NewLogFile creates new LogFile

func (*LogFile) Close Uses

func (w *LogFile) Close() error

Close closes underlying file and signals all readers to stop.

func (*LogFile) MaxFiles Uses

func (w *LogFile) MaxFiles() int

MaxFiles return maximum number of files

func (*LogFile) ReadLogs Uses

func (w *LogFile) ReadLogs(config logger.ReadConfig, watcher *logger.LogWatcher)

ReadLogs decodes entries from log files and sends them the passed in watcher

Note: Using the follow option can become inconsistent in cases with very frequent rotations and max log files is 1. TODO: Consider a different implementation which can effectively follow logs under frequent rotations.

func (*LogFile) WriteLogEntry Uses

func (w *LogFile) WriteLogEntry(msg *logger.Message) 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.

type MakeDecoderFn Uses

type MakeDecoderFn func(rdr io.Reader) Decoder

MakeDecoderFn creates a decoder

type SizeReaderAt Uses

type SizeReaderAt interface {
    Size() int64

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



Package loggerutils imports 20 packages (graph) and is imported by 2460 packages. Updated 2021-01-23. Refresh now. Tools for package owners.