docker: Index | Files | Directories

package logger

import ""

Package logger defines interfaces that logger drivers implement to log messages.

The other half of a logger driver is the implementation of the factory, which holds the contextual instance information that allows multiple loggers of the same type to perform different actions, such as logging to different locations.


Package Files

adapter.go copier.go factory.go log_cache_opts.go logger.go loginfo.go metrics.go plugin.go plugin_unix.go proxy.go ring.go

func AddBuiltinLogOpts Uses

func AddBuiltinLogOpts(opts map[string]bool)

AddBuiltinLogOpts updates the list of built-in log opts. This allows other packages to supplement additional log options without having to register an actual log driver. This is used by things that are more proxy log drivers and should not be exposed as a usable log driver to the API. This should only be called on package initialization.

func ListDrivers Uses

func ListDrivers() []string

ListDrivers gets the list of registered log driver names

func PutMessage Uses

func PutMessage(msg *Message)

PutMessage puts the specified message back n the message pool. The message fields are reset before putting into the pool.

func RegisterExternalValidator Uses

func RegisterExternalValidator(v LogOptValidator)

RegisterExternalValidator adds the validator to the list of external validators. External validators are used by packages outside this package that need to add their own validation logic. This should only be called on package initialization.

func RegisterLogDriver Uses

func RegisterLogDriver(name string, c Creator) error

RegisterLogDriver registers the given logging driver builder with given logging driver name.

func RegisterLogOptValidator Uses

func RegisterLogOptValidator(name string, l LogOptValidator) error

RegisterLogOptValidator registers the logging option validator with the given logging driver name.

func RegisterPluginGetter Uses

func RegisterPluginGetter(plugingetter getter.PluginGetter)

RegisterPluginGetter sets the plugingetter

func ValidateLogOpts Uses

func ValidateLogOpts(name string, cfg map[string]string) error

ValidateLogOpts checks the options for the given log driver. The options supported are specific to the LogDriver implementation.

type Capability Uses

type Capability struct {
    // Determines if a log driver can read back logs
    ReadLogs bool

Capability defines the list of capabilities that a driver can implement These capabilities are not required to be a logging driver, however do determine how a logging driver can be used

type Copier Uses

type Copier struct {
    // contains filtered or unexported fields

Copier can copy logs from specified sources to Logger and attach Timestamp. Writes are concurrent, so you need implement some sync in your logger.

func NewCopier Uses

func NewCopier(srcs map[string]io.Reader, dst Logger) *Copier

NewCopier creates a new Copier

func (*Copier) Close Uses

func (c *Copier) Close()

Close closes the copier

func (*Copier) Run Uses

func (c *Copier) Run()

Run starts logs copying

func (*Copier) Wait Uses

func (c *Copier) Wait()

Wait waits until all copying is done

type Creator Uses

type Creator func(Info) (Logger, error)

Creator builds a logging driver instance with given context.

func GetLogDriver Uses

func GetLogDriver(name string) (Creator, error)

GetLogDriver provides the logging driver builder for a logging driver name.

type ErrReadLogsNotSupported Uses

type ErrReadLogsNotSupported struct{}

ErrReadLogsNotSupported is returned when the underlying log driver does not support reading

func (ErrReadLogsNotSupported) Error Uses

func (ErrReadLogsNotSupported) Error() string

func (ErrReadLogsNotSupported) NotImplemented Uses

func (ErrReadLogsNotSupported) NotImplemented()

NotImplemented makes this error implement the `NotImplemented` interface from api/errdefs

type Info Uses

type Info struct {
    Config              map[string]string
    ContainerID         string
    ContainerName       string
    ContainerEntrypoint string
    ContainerArgs       []string
    ContainerImageID    string
    ContainerImageName  string
    ContainerCreated    time.Time
    ContainerEnv        []string
    ContainerLabels     map[string]string
    LogPath             string
    DaemonName          string

Info provides enough information for a logging driver to do its function.

func (*Info) Command Uses

func (info *Info) Command() string

Command returns the command that the container being logged was started with. The Entrypoint is prepended to the container arguments.

func (*Info) ExtraAttributes Uses

func (info *Info) ExtraAttributes(keyMod func(string) string) (map[string]string, error)

ExtraAttributes returns the user-defined extra attributes (labels, environment variables) in key-value format. This can be used by log drivers that support metadata to add more context to a log.

func (*Info) FullID Uses

func (info *Info) FullID() string

FullID is an alias of ContainerID.

func (*Info) Hostname Uses

func (info *Info) Hostname() (string, error)

Hostname returns the hostname from the underlying OS.

func (*Info) ID Uses

func (info *Info) ID() string

ID Returns the Container ID shortened to 12 characters.

func (*Info) ImageFullID Uses

func (info *Info) ImageFullID() string

ImageFullID is an alias of ContainerImageID.

func (*Info) ImageID Uses

func (info *Info) ImageID() string

ImageID returns the ContainerImageID shortened to 12 characters.

func (*Info) ImageName Uses

func (info *Info) ImageName() string

ImageName is an alias of ContainerImageName

func (*Info) Name Uses

func (info *Info) Name() string

Name returns the ContainerName without a preceding '/'.

type LogOptValidator Uses

type LogOptValidator func(cfg map[string]string) error

LogOptValidator checks the options specific to the underlying logging implementation.

type LogReader Uses

type LogReader interface {
    // Read logs from underlying logging backend
    ReadLogs(ReadConfig) *LogWatcher

LogReader is the interface for reading log messages for loggers that support reading.

type LogWatcher Uses

type LogWatcher struct {
    // For sending log messages to a reader.
    Msg chan *Message
    // For sending error messages that occur while reading logs.
    Err chan error
    // contains filtered or unexported fields

LogWatcher is used when consuming logs read from the LogReader interface.

func NewLogWatcher Uses

func NewLogWatcher() *LogWatcher

NewLogWatcher returns a new LogWatcher.

func (*LogWatcher) ConsumerGone Uses

func (w *LogWatcher) ConsumerGone()

ConsumerGone notifies that the logs consumer is gone.

func (*LogWatcher) ProducerGone Uses

func (w *LogWatcher) ProducerGone()

ProducerGone notifies the underlying log reader that the logs producer (a container) is gone.

func (*LogWatcher) WatchConsumerGone Uses

func (w *LogWatcher) WatchConsumerGone() <-chan struct{}

WatchConsumerGone returns a channel receiver that receives notification when the log watcher consumer is gone.

func (*LogWatcher) WatchProducerGone Uses

func (w *LogWatcher) WatchProducerGone() <-chan struct{}

WatchProducerGone returns a channel receiver that receives notification once the logs producer (a container) is gone.

type Logger Uses

type Logger interface {
    Log(*Message) error
    Name() string
    Close() error

Logger is the interface for docker logging drivers.

func NewRingLogger Uses

func NewRingLogger(driver Logger, logInfo Info, maxSize int64) Logger

NewRingLogger creates a new Logger that is implemented as a RingBuffer wrapping the passed in logger.

type MarshalFunc Uses

type MarshalFunc func(*Message) ([]byte, error)

MarshalFunc is a func that marshals a message into an arbitrary format

type Message Uses

type Message backend.LogMessage

Message is data structure that represents piece of output produced by some container. The Line member is a slice of an array whose contents can be changed after a log driver's Log() method returns.

Message is subtyped from backend.LogMessage because there is a lot of internal complexity around the Message type that should not be exposed to any package not explicitly importing the logger type.

Any changes made to this struct must also be updated in the `reset` function

func NewMessage Uses

func NewMessage() *Message

NewMessage returns a new message from the message sync.Pool

func (*Message) AsLogMessage Uses

func (m *Message) AsLogMessage() *backend.LogMessage

AsLogMessage returns a pointer to the message as a pointer to backend.LogMessage, which is an identical type with a different purpose

type ReadConfig Uses

type ReadConfig struct {
    Since  time.Time
    Until  time.Time
    Tail   int
    Follow bool

ReadConfig is the configuration passed into ReadLogs.

type RingLogger Uses

type RingLogger struct {
    // contains filtered or unexported fields

RingLogger is a ring buffer that implements the Logger interface. This is used when lossy logging is OK.

func (*RingLogger) Close Uses

func (r *RingLogger) Close() error

Close closes the logger

func (*RingLogger) Log Uses

func (r *RingLogger) Log(msg *Message) error

Log queues messages into the ring buffer

func (*RingLogger) Name Uses

func (r *RingLogger) Name() string

Name returns the name of the underlying logger

type SizedLogger Uses

type SizedLogger interface {
    BufSize() int

SizedLogger is the interface for logging drivers that can control the size of buffer used for their messages.


awslogsPackage awslogs provides the logdriver for forwarding container logs to Amazon CloudWatch Logs
etwlogsPackage etwlogs provides a log driver for forwarding container logs as ETW events.(ETW stands for Event Tracing for Windows) A client can then create an ETW listener to listen for events that are sent by the ETW provider that we register, using the provider's GUID "a3693192-9ed6-46d2-a981-f8226c8363bd".
fluentdPackage fluentd provides the log driver for forwarding server logs to fluentd endpoints.
gelfPackage gelf provides the log driver for forwarding server logs to endpoints that support the Graylog Extended Log Format.
journaldPackage journald provides the log driver for forwarding server logs to endpoints that receive the systemd format.
jsonfilelogPackage jsonfilelog provides the default Logger implementation for Docker logging.
localPackage local provides a logger implementation that stores logs on disk.
logentriesPackage logentries provides the log driver for forwarding server logs to logentries endpoints.
splunkPackage splunk provides the log driver for forwarding server logs to Splunk HTTP Event Collector endpoint.
syslogPackage syslog provides the logdriver for forwarding server logs to syslog endpoints.

Package logger imports 26 packages (graph) and is imported by 5966 packages. Updated 2020-11-09. Refresh now. Tools for package owners.