Documentation ¶
Overview ¶
Forked from https://github.com/kubernetes/kubernetes/blob/cc60b26dee4768e3c5aa0515bbf4ba1824ad38dc/staging/src/k8s.io/cri-client/pkg/logs/logs_other.go Copyright The Kubernetes Authors. Licensed under the Apache License, Version 2.0
Index ¶
- Constants
- Variables
- func Drivers() []string
- func FetchLogs(stdout, stderr io.Writer, journalctlArgs []string, stopChannel chan os.Signal) error
- func FluentdLogOptsValidate(logOptMap map[string]string) error
- func JSONFileLogOptsValidate(logOptMap map[string]string) error
- func JournalLogOptsValidate(logOptMap map[string]string) error
- func LogConfigFilePath(dataStore, ns, id string) string
- func Main(argv2 string) error
- func NewLogFileWatcher(dir string) (*fsnotify.Watcher, error)
- func NoneLogOptsValidate(_ map[string]string) error
- func ParseCRILog(log []byte, msg *logMessage) error
- func ReadLogs(opts *LogViewOptions, stdout, stderr io.Writer, stopChannel chan os.Signal) error
- func RegisterDriver(name string, f DriverFactory, validateFunc LogOptsValidateFunc)
- func RegisterLogViewer(driverName string, lvfn LogViewerFunc)
- func SyslogOptsValidate(logOptMap map[string]string) error
- func ValidateFluentdLoggerOpts(config map[string]string) error
- func ValidateLogOpts(logDriver string, logOpts map[string]string) error
- type ContainerLogViewer
- type Driver
- type DriverFactory
- type FluentdLogger
- type JSONLogger
- func (jsonLogger *JSONLogger) Init(dataStore, ns, id string) error
- func (jsonLogger *JSONLogger) PostProcess() error
- func (jsonLogger *JSONLogger) PreProcess(ctx context.Context, dataStore string, config *logging.Config) error
- func (jsonLogger *JSONLogger) Process(stdout <-chan string, stderr <-chan string) error
- type JournaldLogger
- func (journaldLogger *JournaldLogger) Init(dataStore, ns, id string) error
- func (journaldLogger *JournaldLogger) PostProcess() error
- func (journaldLogger *JournaldLogger) PreProcess(ctx context.Context, dataStore string, config *logging.Config) error
- func (journaldLogger *JournaldLogger) Process(stdout <-chan string, stderr <-chan string) error
- type LogConfig
- type LogOptsValidateFunc
- type LogStreamType
- type LogTag
- type LogViewOptions
- type LogViewerFunc
- type NoneLogger
- type SyslogLogger
- func (sy *SyslogLogger) Init(dataStore string, ns string, id string) error
- func (sy *SyslogLogger) PostProcess() error
- func (sy *SyslogLogger) PreProcess(ctx context.Context, dataStore string, config *logging.Config) error
- func (sy *SyslogLogger) Process(stdout <-chan string, stderr <-chan string) error
Constants ¶
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 ¶
var FluentdLogOpts = []string{ fluentAddress, fluentdAsync, fluentdBufferLimit, fluentdRetryWait, fluentdMaxRetries, fluentdSubSecondPrecision, fluentdAsyncReconnectInterval, fluentRequestAck, Tag, }
var JSONDriverLogOpts = []string{ LogPath, MaxSize, MaxFile, }
var JournalDriverLogOpts = []string{ Tag, }
Functions ¶
func FetchLogs ¶
Exec's `journalctl` with the provided arguments and hooks it up to the given stdout/stderr streams.
func FluentdLogOptsValidate ¶
func JSONFileLogOptsValidate ¶
func JournalLogOptsValidate ¶
func LogConfigFilePath ¶
LogConfigFilePath returns the path of log-config.json
func Main ¶
Main is the entrypoint for the containerd runtime v2 logging plugin mode.
Should be called only if argv1 == MagicArgv1.
func NoneLogOptsValidate ¶
func ParseCRILog ¶
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 ¶
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 ¶
func RegisterDriver(name string, f DriverFactory, validateFunc LogOptsValidateFunc)
func RegisterLogViewer ¶
func RegisterLogViewer(driverName string, lvfn LogViewerFunc)
Registers a LogViewerFunc for the
func SyslogOptsValidate ¶
Types ¶
type ContainerLogViewer ¶
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 ¶
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 ¶
func (lv *ContainerLogViewer) PrintLogsTo(stdout, stderr io.Writer) error
Prints all logs for this LogViewer's containers to the provided io.Writers.
type Driver ¶
type FluentdLogger ¶
func (*FluentdLogger) Init ¶
func (f *FluentdLogger) Init(dataStore, ns, id string) error
func (*FluentdLogger) PostProcess ¶
func (f *FluentdLogger) PostProcess() error
func (*FluentdLogger) PreProcess ¶
type JSONLogger ¶
func (*JSONLogger) Init ¶
func (jsonLogger *JSONLogger) Init(dataStore, ns, id string) error
func (*JSONLogger) PostProcess ¶
func (jsonLogger *JSONLogger) PostProcess() error
func (*JSONLogger) PreProcess ¶
type JournaldLogger ¶
type JournaldLogger struct { Opts map[string]string Address string // contains filtered or unexported fields }
func (*JournaldLogger) Init ¶
func (journaldLogger *JournaldLogger) Init(dataStore, ns, id string) error
func (*JournaldLogger) PostProcess ¶
func (journaldLogger *JournaldLogger) PostProcess() error
func (*JournaldLogger) PreProcess ¶
type LogConfig ¶
type LogConfig struct { Driver string `json:"driver"` Opts map[string]string `json:"opts,omitempty"` LogURI string `json:"-"` Address string `json:"address"` }
LogConfig is marshalled as "log-config.json"
func LoadLogConfig ¶
LoadLogConfig loads the log-config.json for the afferrent container store
type LogOptsValidateFunc ¶
type LogStreamType ¶
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 ¶
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.
type LogViewOptions ¶
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 ¶
func (lvo *LogViewOptions) Validate() error
type LogViewerFunc ¶
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 NoneLogger ¶
func (*NoneLogger) Init ¶
func (n *NoneLogger) Init(dataStore, ns, id string) error
func (*NoneLogger) PostProcess ¶
func (n *NoneLogger) PostProcess() error
func (*NoneLogger) PreProcess ¶
type SyslogLogger ¶
func (*SyslogLogger) Init ¶
func (sy *SyslogLogger) Init(dataStore string, ns string, id string) error
func (*SyslogLogger) PostProcess ¶
func (sy *SyslogLogger) PostProcess() error