logger

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TimeFormat is the time format used for timestamps sent to log readers
	TimeFormat = timeutils.RFC3339NanoFixed
)

Variables

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

ErrReadLogsNotSupported is returned when the logger does not support reading logs

Functions

func RegisterLogDriver added in v1.7.0

func RegisterLogDriver(name string, c Creator) error

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

func RegisterLogOptValidator added in v1.8.0

func RegisterLogOptValidator(name string, l LogOptValidator) error

func ValidateLogOpts added in v1.8.0

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

Types

type Context added in v1.7.0

type Context struct {
	Config              map[string]string
	ContainerID         string
	ContainerName       string
	ContainerEntrypoint string
	ContainerArgs       []string
	ContainerImageID    string
	ContainerImageName  string
	ContainerCreated    time.Time
	LogPath             string
}

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

func (*Context) Command added in v1.8.0

func (ctx *Context) Command() string

Command returns the command that the container being logged was started with

func (*Context) Hostname added in v1.8.0

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

Hostname returns the hostname from the underlying OS

type Copier

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

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

NewCopier creates new 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 added in v1.7.0

type Creator func(Context) (Logger, error)

Creator is a method that builds a logging driver instance with given context

func GetLogDriver added in v1.7.0

func GetLogDriver(name string) (Creator, error)

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

type LogOptValidator added in v1.8.0

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

LogOptValidator is a method that validates the log opts provided

type LogReader added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

func NewLogWatcher() *LogWatcher

NewLogWatcher returns a new LogWatcher.

func (*LogWatcher) Close added in v1.8.0

func (w *LogWatcher) Close()

Close notifies the underlying log reader to stop

func (*LogWatcher) WatchClose added in v1.8.0

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

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

Logger is the interface for docker logging drivers

type Message

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

Message is datastructure that represents record from some container

type ReadConfig added in v1.8.0

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

ReadConfig is the configuration passed into ReadLogs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL