Documentation ¶
Overview ¶
Package logger provides shim loggers for Containerd.
Index ¶
- Constants
- func NewInfo(containerID string, containerName string, options ...InfoOpt) *dockerlogger.Info
- func SetUIDAndGID(uid int, gid int) error
- func UpdateDockerConfigs(info *dockerlogger.Info, dockerConfigs *DockerConfigs) *dockerlogger.Info
- type Client
- type DockerConfigs
- type GlobalArgs
- type InfoOpt
- type LogDriver
- type Logger
- func (l *Logger) GetPipes() (map[string]io.Reader, error)
- func (l *Logger) Log(message *dockerlogger.Message) error
- func (l *Logger) Read(ctx context.Context, pipe io.Reader, source string, bufferSizeInBytes int, ...) error
- func (l *Logger) Start(ctx context.Context, cleanupTime *time.Duration, ready func() error) error
- type Opt
- type WindowsArgs
Constants ¶
const ( // DaemonName represents the name of the shim logger daemon for containerd. DaemonName = "shim-loggers-for-containerd" // NonBlockingMode indicates the mode of logger which doesn't block on logging. NonBlockingMode = "non-blocking" // DefaultBufSizeInBytes provides a reasonable default for loggers that do // not have an external limit to impose on log line size. Adopted this value // from Docker, reference: // https://github.com/moby/moby/blob/19.03/daemon/logger/copier.go#L21 DefaultBufSizeInBytes = 16 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func NewInfo ¶
func NewInfo(containerID string, containerName string, options ...InfoOpt) *dockerlogger.Info
NewInfo creates the placeholder info. Expected that relevant parts will be modified via the common_opts.
func SetUIDAndGID ¶
SetUIDAndGID sets UID and/or GID for current goroutine/process. If you are building with go version includes the following commit, you only need to call this once. Otherwise you need call this function in all goroutines. Commit: https://github.com/golang/go/commit/d1b1145cace8b968307f9311ff611e4bb810710c TODO: remove the above comment once the changes are released: https://go-review.googlesource.com/c/go/+/210639
func UpdateDockerConfigs ¶
func UpdateDockerConfigs(info *dockerlogger.Info, dockerConfigs *DockerConfigs) *dockerlogger.Info
UpdateDockerConfigs updates the docker config fields to the logger info.
Types ¶
type Client ¶
type Client interface {
Log(*dockerlogger.Message) error
}
Client is a wrapper for docker logger's Log method, which is mostly used for testing purposes.
type DockerConfigs ¶
type DockerConfigs struct { // ContainerImageID is the ID of the container image. ContainerImageID string // ContainerImageName is the name of the container image. ContainerImageName string // ContainerEnv contains environment variables of the container. ContainerEnv []string // ContainerLabels holds labels associated with the container. ContainerLabels map[string]string }
DockerConfigs holds optional Docker configuration details.
type GlobalArgs ¶
type GlobalArgs struct { // Required arguments ContainerID string ContainerName string LogDriver string // Optional arguments Mode string MaxBufferSize int UID int GID int CleanupTime *time.Duration }
GlobalArgs contains the essential arguments required for initializing the logger.
type InfoOpt ¶
type InfoOpt func(*dockerlogger.Info)
InfoOpt is a type of function that is used to update the values of fields in logger info for each driver. Field supported to be modified is config.
func WithConfig ¶
WithConfig sets logger config of logger info.
type LogDriver ¶
type LogDriver interface { // Start functions starts sending container logs to destination. Start(context.Context, *time.Duration, func() error) error // GetPipes gets pipes of container that exposed by containerd. GetPipes() (map[string]io.Reader, error) // Log sends logs to destination. Log(*dockerlogger.Message) error // Read reads a single log message from container pipe and sends it to // destination or saves it to ring buffer, depending on the mode of log // driver. Read(context.Context, io.Reader, string, int, sendLogToDestFunc) error }
LogDriver is the interface for all log drivers.
type Logger ¶
type Logger struct { Info *dockerlogger.Info Stream Client Stdout io.Reader Stderr io.Reader // contains filtered or unexported fields }
Logger is the basic struct for all log drivers.
func (*Logger) Log ¶
func (l *Logger) Log(message *dockerlogger.Message) error
Log sends logs to destination.
func (*Logger) Read ¶
func (l *Logger) Read( ctx context.Context, pipe io.Reader, source string, bufferSizeInBytes int, sendLogMsgToDest sendLogToDestFunc, ) error
Read gets container logs, saves them to our own buffer. Then we will read logs line by line and send them to destination. In non-blocking mode, the destination is the ring buffer. More log messages will be sent in verbose mode for debugging.
type Opt ¶
type Opt func(*Logger)
Opt is a type of function that is used to update the values of fields in LoggerArgs. Fields supported to be modified are logger info, stdout and stderr.
func WithBufferSizeInBytes ¶
WithBufferSizeInBytes sets the buffer size of log driver.
func WithMaxReadBytes ¶
WithMaxReadBytes sets how many bytes will be read from container pipe per iteration.
func WithStream ¶
WithStream sets the actual stream of log driver.
type WindowsArgs ¶
WindowsArgs struct for Windows configuration.
Directories ¶
Path | Synopsis |
---|---|
Package awslogs provides functionalities for integrating the awslogs logging driver with shim-loggers-for-containerd.
|
Package awslogs provides functionalities for integrating the awslogs logging driver with shim-loggers-for-containerd. |
Package fluentd provides functionalities for integrating the fluentd logging driver with shim-loggers-for-containerd.
|
Package fluentd provides functionalities for integrating the fluentd logging driver with shim-loggers-for-containerd. |
Package mock_logger is a generated GoMock package.
|
Package mock_logger is a generated GoMock package. |
Package splunk provides functionalities for integrating the splunk logging driver with shim-loggers-for-containerd.
|
Package splunk provides functionalities for integrating the splunk logging driver with shim-loggers-for-containerd. |