package logger
import "github.com/docker/docker/daemon/logger"
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.
Index ¶
- Constants
- Variables
- func RegisterLogDriver(name string, c Creator) error
- func RegisterLogOptValidator(name string, l LogOptValidator) error
- func ValidateLogOpts(name string, cfg map[string]string) error
- type Context
- func (ctx *Context) Command() string
- func (ctx *Context) ExtraAttributes(keyMod func(string) string) map[string]string
- func (ctx *Context) FullID() string
- func (ctx *Context) Hostname() (string, error)
- func (ctx *Context) ID() string
- func (ctx *Context) ImageFullID() string
- func (ctx *Context) ImageID() string
- func (ctx *Context) ImageName() string
- func (ctx *Context) Name() string
- type Copier
- func NewCopier(srcs map[string]io.Reader, dst Logger) *Copier
- func (c *Copier) Close()
- func (c *Copier) Run()
- func (c *Copier) Wait()
- type Creator
- type LogAttributes
- type LogOptValidator
- type LogReader
- type LogWatcher
- func NewLogWatcher() *LogWatcher
- func (w *LogWatcher) Close()
- func (w *LogWatcher) WatchClose() <-chan struct{}
- type Logger
- type Message
- type ReadConfig
Constants ¶
const ( // TimeFormat is the time format used for timestamps sent to log readers. TimeFormat = jsonlog.RFC3339NanoFixed )
Variables ¶
ErrReadLogsNotSupported is returned when the logger does not support reading logs.
Functions ¶
func RegisterLogDriver ¶
RegisterLogDriver registers the given logging driver builder with given logging driver name.
func RegisterLogOptValidator ¶
func RegisterLogOptValidator(name string, l LogOptValidator) error
RegisterLogOptValidator registers the logging option validator with the given logging driver name.
func ValidateLogOpts ¶
ValidateLogOpts checks the options for the given log driver. The options supported are specific to the LogDriver implementation.
Types ¶
type Context ¶
type Context 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 }
Context provides enough information for a logging driver to do its function.
func (*Context) Command ¶
Command returns the command that the container being logged was started with. The Entrypoint is prepended to the container arguments.
func (*Context) ExtraAttributes ¶
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 (*Context) FullID ¶
FullID is an alias of ContainerID.
func (*Context) Hostname ¶
Hostname returns the hostname from the underlying OS.
func (*Context) ID ¶
ID Returns the Container ID shortened to 12 characters.
func (*Context) ImageFullID ¶
ImageFullID is an alias of ContainerImageID.
func (*Context) ImageID ¶
ImageID returns the ContainerImageID shortened to 12 characters.
func (*Context) ImageName ¶
ImageName is an alias of ContainerImageName
func (*Context) Name ¶
Name returns the ContainerName without a preceding '/'.
type Copier ¶
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 ¶
NewCopier creates a new Copier
func (*Copier) Close ¶
func (c *Copier) Close()
Close closes the copier
func (*Copier) Run ¶
func (c *Copier) Run()
Run starts logs copying
func (*Copier) Wait ¶
func (c *Copier) Wait()
Wait waits until all copying is done
type Creator ¶
Creator builds a logging driver instance with given context.
func GetLogDriver ¶
GetLogDriver provides the logging driver builder for a logging driver name.
type LogAttributes ¶
LogAttributes is used to hold the extra attributes available in the log message Primarily used for converting the map type to string and sorting.
func (LogAttributes) String ¶
func (a LogAttributes) String() string
type LogOptValidator ¶
LogOptValidator checks the options specific to the underlying logging implementation.
type LogReader ¶
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 ¶
type LogWatcher struct { // For sending log messages to a reader. Msg chan *Message // For sending error messages that occur while while reading logs. Err chan error // contains filtered or unexported fields }
LogWatcher is used when consuming logs read from the LogReader interface.
func NewLogWatcher ¶
func NewLogWatcher() *LogWatcher
NewLogWatcher returns a new LogWatcher.
func (*LogWatcher) Close ¶
func (w *LogWatcher) Close()
Close notifies the underlying log reader to stop.
func (*LogWatcher) WatchClose ¶
func (w *LogWatcher) WatchClose() <-chan struct{}
WatchClose returns a channel receiver that receives notification when the watcher has been closed. This should only be called from one goroutine.
type Logger ¶
Logger is the interface for docker logging drivers.
type Message ¶
type Message struct { Line []byte Source string Timestamp time.Time Attrs LogAttributes Partial bool }
Message is datastructure 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.
func CopyMessage ¶
CopyMessage creates a copy of the passed-in Message which will remain unchanged if the original is changed. Log drivers which buffer Messages rather than dispatching them during their Log() method should use this function to obtain a Message whose Line member's contents won't change.
type ReadConfig ¶
ReadConfig is the configuration passed into ReadLogs.
Source Files ¶
context.go copier.go factory.go logger.go
Directories ¶
Path | Synopsis |
---|---|
daemon/logger/awslogs | Package awslogs provides the logdriver for forwarding container logs to Amazon CloudWatch Logs |
daemon/logger/fluentd | Package fluentd provides the log driver for forwarding server logs to fluentd endpoints. |
daemon/logger/gcplogs | |
daemon/logger/gelf | |
daemon/logger/journald | |
daemon/logger/jsonfilelog | Package jsonfilelog provides the default Logger implementation for Docker logging. |
daemon/logger/logentries | Package logentries provides the log driver for forwarding server logs to logentries endpoints. |
daemon/logger/loggerutils | |
daemon/logger/splunk | Package splunk provides the log driver for forwarding server logs to Splunk HTTP Event Collector endpoint. |
daemon/logger/syslog | Package syslog provides the logdriver for forwarding server logs to syslog endpoints. |
- Version
- v1.13.0-rc5
- Published
- Jan 4, 2017
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 43 minutes ago –
Tools for package owners.