logging

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MagicArgv1 is the magic argv1 for the containerd runtime v2 logging plugin mode.
	MagicArgv1 = "_NERDCTL_INTERNAL_LOGGING"
	LogPath    = "log-path"
	MaxSize    = "max-size"
	MaxFile    = "max-file"
	Tag        = "tag"
)

Variables

View Source
var FluentdLogOpts = []string{
	fluentAddress,
	fluentdAsync,
	fluentdBufferLimit,
	fluentdRetryWait,
	fluentdMaxRetries,
	fluentdSubSecondPrecision,
	fluentdAsyncReconnectInterval,
	fluentRequestAck,
	Tag,
}
View Source
var JSONDriverLogOpts = []string{
	LogPath,
	MaxSize,
	MaxFile,
}
View Source
var JournalDriverLogOpts = []string{
	Tag,
}

Functions

func Drivers added in v0.21.0

func Drivers() []string

func FetchLogs added in v0.21.0

func FetchLogs(stdout, stderr io.Writer, journalctlArgs []string, stopChannel chan os.Signal) error

Exec's `journalctl` with the provided arguments and hooks it up to the given stdout/stderr streams.

func FluentdLogOptsValidate added in v0.22.1

func FluentdLogOptsValidate(logOptMap map[string]string) error

func JSONFileLogOptsValidate added in v0.22.1

func JSONFileLogOptsValidate(logOptMap map[string]string) error

func JournalLogOptsValidate added in v0.22.1

func JournalLogOptsValidate(logOptMap map[string]string) error

func LogConfigFilePath added in v0.20.0

func LogConfigFilePath(dataStore, ns, id string) string

LogConfigFilePath returns the path of log-config.json

func Main

func Main(argv2 string) error

Main is the entrypoint for the containerd runtime v2 logging plugin mode.

Should be called only if argv1 == MagicArgv1.

func ParseCRILog added in v1.2.0

func ParseCRILog(log []byte, msg *logMessage) error

ParseCRILog parses logs in CRI log format. CRI Log format example:

2016-10-06T00:17:09.669794202Z stdout P log content 1
2016-10-06T00:17:09.669794203Z stderr F log content 2

func ReadLogs added in v1.2.0

func ReadLogs(opts *LogViewOptions, stdout, stderr io.Writer, stopChannel chan os.Signal) error

ReadLogs read the container log and redirect into stdout and stderr. Note that containerID is only needed when following the log, or else just pass in empty string "".

func RegisterDriver added in v0.21.0

func RegisterDriver(name string, f DriverFactory, validateFunc LogOptsValidateFunc)

func RegisterLogViewer added in v1.1.0

func RegisterLogViewer(driverName string, lvfn LogViewerFunc)

Registers a LogViewerFunc for the

func SyslogOptsValidate added in v1.0.0

func SyslogOptsValidate(logOptMap map[string]string) error

func ValidateFluentdLoggerOpts added in v0.21.0

func ValidateFluentdLoggerOpts(config map[string]string) error

func ValidateLogOpts added in v0.22.1

func ValidateLogOpts(logDriver string, logOpts map[string]string) error

Types

type ContainerLogViewer added in v1.1.0

type ContainerLogViewer struct {
	// contains filtered or unexported fields
}

Implements functionality for loading the logging configuration and fetching/outputting container logs based on its internal LogViewOptions.

func InitContainerLogViewer added in v1.1.0

func InitContainerLogViewer(containerLabels map[string]string, lvopts LogViewOptions, stopChannel chan os.Signal, experimental bool) (contlv *ContainerLogViewer, err error)

Validates the given LogViewOptions, loads the logging config for the given container and returns a ContainerLogViewer.

func (*ContainerLogViewer) PrintLogsTo added in v1.1.0

func (lv *ContainerLogViewer) PrintLogsTo(stdout, stderr io.Writer) error

Prints all logs for this LogViewer's containers to the provided io.Writers.

type Driver added in v0.21.0

type Driver interface {
	Init(dataStore, ns, id string) error
	PreProcess(dataStore string, config *logging.Config) error
	Process(stdout <-chan string, stderr <-chan string) error
	PostProcess() error
}

func GetDriver added in v0.21.0

func GetDriver(name string, opts map[string]string) (Driver, error)

type DriverFactory added in v0.21.0

type DriverFactory func(map[string]string) (Driver, error)

type FluentdLogger added in v0.21.0

type FluentdLogger struct {
	Opts map[string]string
	// contains filtered or unexported fields
}

func (*FluentdLogger) Init added in v0.21.0

func (f *FluentdLogger) Init(dataStore, ns, id string) error

func (*FluentdLogger) PostProcess added in v1.1.0

func (f *FluentdLogger) PostProcess() error

func (*FluentdLogger) PreProcess added in v1.1.0

func (f *FluentdLogger) PreProcess(_ string, config *logging.Config) error

func (*FluentdLogger) Process added in v0.21.0

func (f *FluentdLogger) Process(stdout <-chan string, stderr <-chan string) error

type JSONLogger added in v0.22.0

type JSONLogger struct {
	Opts map[string]string
	// contains filtered or unexported fields
}

func (*JSONLogger) Init added in v0.22.0

func (jsonLogger *JSONLogger) Init(dataStore, ns, id string) error

func (*JSONLogger) PostProcess added in v1.1.0

func (jsonLogger *JSONLogger) PostProcess() error

func (*JSONLogger) PreProcess added in v1.1.0

func (jsonLogger *JSONLogger) PreProcess(dataStore string, config *logging.Config) error

func (*JSONLogger) Process added in v0.22.0

func (jsonLogger *JSONLogger) Process(stdout <-chan string, stderr <-chan string) error

type JournaldLogger added in v0.21.0

type JournaldLogger struct {
	Opts map[string]string
	// contains filtered or unexported fields
}

func (*JournaldLogger) Init added in v0.21.0

func (journaldLogger *JournaldLogger) Init(dataStore, ns, id string) error

func (*JournaldLogger) PostProcess added in v1.1.0

func (journaldLogger *JournaldLogger) PostProcess() error

func (*JournaldLogger) PreProcess added in v1.1.0

func (journaldLogger *JournaldLogger) PreProcess(dataStore string, config *logging.Config) error

func (*JournaldLogger) Process added in v0.21.0

func (journaldLogger *JournaldLogger) Process(stdout <-chan string, stderr <-chan string) error

type LogConfig added in v0.20.0

type LogConfig struct {
	Driver string            `json:"driver"`
	Opts   map[string]string `json:"opts,omitempty"`
	LogURI string            `json:"-"`
}

LogConfig is marshalled as "log-config.json"

func LoadLogConfig added in v1.1.0

func LoadLogConfig(dataStore, ns, id string) (LogConfig, error)

LoadLogConfig loads the log-config.json for the afferrent container store

type LogOptsValidateFunc added in v1.7.1

type LogOptsValidateFunc func(logOptMap map[string]string) error

type LogStreamType added in v1.2.0

type LogStreamType string

LogStreamType is the type of the stream in CRI container log.

const (
	// Stdout is the stream type for stdout.
	Stdout LogStreamType = "stdout"
	// Stderr is the stream type for stderr.
	Stderr LogStreamType = "stderr"
)

type LogTag added in v1.2.0

type LogTag string

LogTag is the tag of a log line in CRI container log. Currently defined log tags: * First tag: Partial/Full - P/F. The field in the container log format can be extended to include multiple tags by using a delimiter, but changes should be rare. If it becomes clear that better extensibility is desired, a more extensible format (e.g., json) should be adopted as a replacement and/or addition.

const (
	// LogTagPartial means the line is part of multiple lines.
	LogTagPartial LogTag = "P"
	// LogTagFull means the line is a single full line or the end of multiple lines.
	LogTagFull LogTag = "F"
	// LogTagDelimiter is the delimiter for different log tags.
	LogTagDelimiter = ":"
)

type LogViewOptions added in v1.1.0

type LogViewOptions struct {
	// Identifier (ID) of the container and namespace it's in.
	ContainerID string
	Namespace   string

	// Absolute path to the nerdctl datastore's root.
	DatastoreRootPath string

	// LogPath specify the log path for container created via CRI
	LogPath string

	// Whether or not to follow the output of the container logs.
	Follow bool

	// Whether or not to print timestampts for each line.
	Timestamps bool

	// Uint representing the number of most recent log entries to display. 0 = "all".
	Tail uint

	// Start/end timestampts to filter logs by.
	Since string
	Until string
}

Set of options passable to log viewers.

func (*LogViewOptions) Validate added in v1.1.0

func (lvo *LogViewOptions) Validate() error

type LogViewerFunc added in v1.1.0

type LogViewerFunc func(lvopts LogViewOptions, stdout, stderr io.Writer, stopChannel chan os.Signal) error

Type alias for functions which write out logs to the provided stdout/stderr Writers. Depending on the provided `LogViewOptions.Follow` option, the function may block indefinitely until something is sent through the `stopChannel`.

type SyslogLogger added in v1.0.0

type SyslogLogger struct {
	Opts map[string]string
	// contains filtered or unexported fields
}

func (*SyslogLogger) Init added in v1.0.0

func (sy *SyslogLogger) Init(dataStore string, ns string, id string) error

func (*SyslogLogger) PostProcess added in v1.1.0

func (sy *SyslogLogger) PostProcess() error

func (*SyslogLogger) PreProcess added in v1.1.0

func (sy *SyslogLogger) PreProcess(dataStore string, config *logging.Config) error

func (*SyslogLogger) Process added in v1.0.0

func (sy *SyslogLogger) Process(stdout <-chan string, stderr <-chan string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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