hypercli: github.com/hyperhq/hypercli/daemon/logger Index | Files | Directories

package logger

import "github.com/hyperhq/hypercli/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.


Package Files

context.go copier.go factory.go logger.go


const (
    // TimeFormat is the time format used for timestamps sent to log readers.
    TimeFormat = jsonlog.RFC3339NanoFixed


var ErrReadLogsNotSupported = errors.New("configured logging reader does not support reading")

ErrReadLogsNotSupported is returned when the logger does not support reading logs.

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 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 Context Uses

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

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

func (*Context) Command Uses

func (ctx *Context) Command() string

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

func (*Context) ExtraAttributes Uses

func (ctx *Context) ExtraAttributes(keyMod func(string) string) map[string]string

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 Uses

func (ctx *Context) FullID() string

FullID is an alias of ContainerID.

func (*Context) Hostname Uses

func (ctx *Context) Hostname() (string, error)

Hostname returns the hostname from the underlying OS.

func (*Context) ID Uses

func (ctx *Context) ID() string

ID Returns the Container ID shortened to 12 characters.

func (*Context) ImageFullID Uses

func (ctx *Context) ImageFullID() string

ImageFullID is an alias of ContainerImageID.

func (*Context) ImageID Uses

func (ctx *Context) ImageID() string

ImageID returns the ContainerImageID shortened to 12 characters.

func (*Context) ImageName Uses

func (ctx *Context) ImageName() string

ImageName is an alias of ContainerImageName

func (*Context) Name Uses

func (ctx *Context) Name() string

Name returns the ContainerName without a preceding '/'.

type Copier Uses

type Copier struct {
    // contains filtered or unexported fields

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

func NewCopier Uses

func NewCopier(cid string, 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(Context) (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 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 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) Close Uses

func (w *LogWatcher) Close()

Close notifies the underlying log reader to stop.

func (*LogWatcher) WatchClose Uses

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 Uses

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

Logger is the interface for docker logging drivers.

type Message Uses

type Message struct {
    ContainerID string
    Line        []byte
    Source      string
    Timestamp   time.Time

Message is datastructure that represents record from some container.

type ReadConfig Uses

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

ReadConfig is the configuration passed into ReadLogs.


awslogsPackage awslogs provides the logdriver for forwarding container logs to Amazon CloudWatch Logs
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.
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 11 packages (graph) and is imported by 36 packages. Updated 2017-12-13. Refresh now. Tools for package owners.