rainbond: github.com/goodrain/rainbond/node/nodem/logger Index | Files | Directories

package logger

import "github.com/goodrain/rainbond/node/nodem/logger"


Package Files

copier.go factory.go logger.go logger_file.go logoinfo.go manage.go


var ErrNeglectedContainer = fmt.Errorf("Neglected container")

ErrNeglectedContainer not define logger name

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

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

var RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"

RFC3339NanoFixed time format

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

type ContainerEvent struct {
    Action    string
    Container types.ContainerJSON

ContainerEvent container event

type ContainerLog Uses

type ContainerLog struct {
    LogCopier *Copier
    LogDriver []Logger
    // contains filtered or unexported fields

ContainerLog container log struct

func (*ContainerLog) Close Uses

func (container *ContainerLog) Close()

Close close

func (*ContainerLog) Restart Uses

func (container *ContainerLog) Restart()

Restart restart

func (*ContainerLog) StartLogging Uses

func (container *ContainerLog) StartLogging() error

StartLogging start copy log

func (*ContainerLog) Stop Uses

func (container *ContainerLog) Stop()

Stop stop copy container log

type ContainerLogManage Uses

type ContainerLogManage struct {
    // contains filtered or unexported fields

ContainerLogManage container log manage

func CreatContainerLogManage Uses

func CreatContainerLogManage(conf *option.Conf) *ContainerLogManage

CreatContainerLogManage create a container log manage

func (*ContainerLogManage) Start Uses

func (c *ContainerLogManage) Start() error

Start start

func (*ContainerLogManage) Stop Uses

func (c *ContainerLogManage) Stop()

Stop stop all logger

type ContainerLoggerConfig Uses

type ContainerLoggerConfig struct {
    Name    string
    Options map[string]string

ContainerLoggerConfig logger config

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(logfile *LogFile, dst []Logger, since time.Time) *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

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

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

type LogAttributes map[string]string

LogAttributes is used to hold the extra attributes available in the log message Primarily used for converting the map type to string and sorting.

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, maxFiles int, compress bool, decodeFunc makeDecoderFunc, perms os.FileMode, getTailReader GetTailReaderFunc) (*LogFile, error)

NewLogFile creates new LogFile

func (*LogFile) Close Uses

func (w *LogFile) Close() error

Close file close

func (*LogFile) ReadLogs Uses

func (w *LogFile) ReadLogs(config ReadConfig, watcher *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.

type LogOptValidator Uses

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

LogOptValidator checks the options specific to the underlying logging implementation.

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) 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) 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.

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.

type Message Uses

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. 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

type ReadConfig Uses

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

ReadConfig read log config

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 logger imports 25 packages (graph) and is imported by 3 packages. Updated 2019-08-23. Refresh now. Tools for package owners.