logs

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package logs provides the standard interface and handler for OpenFaaS providers to expose function logs.

The package defines the Requester interface that OpenFaaS providers should implement and then expose using the predefined NewLogHandlerFunc. See the example folder for a minimal log provider implementation.

The Requester is where the actual specific logic for connecting to and querying the log system should be implemented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogHandlerFunc

func NewLogHandlerFunc(requestor Requester, timeout time.Duration) http.HandlerFunc

NewLogHandlerFunc creates an http HandlerFunc from the supplied log Requestor.

Types

type Message

type Message struct {
	// Name is the function name
	Name string `json:"name"`
	// Namespace is the namespace the function is deployed to, how a namespace is defined
	// is faas-provider specific
	Namespace string `json:"namespace"`
	// instance is the name/id of the specific function instance
	Instance string `json:"instance"`
	// Timestamp is the timestamp of when the log message was recorded
	Timestamp time.Time `json:"timestamp"`
	// Text is the raw log message content
	Text string `json:"text"`
}

Message is a specific log message from a function container log stream

func (Message) String

func (m Message) String() string

String implements the Stringer interface and allows for nice and simple string formatting of a log Message.

type Request

type Request struct {
	// Name is the function name and is required
	Name string `json:"name"`
	// Namespace is the namespace the function is deployed to, how a namespace is defined
	// is faas-provider specific
	Namespace string `json:"namespace"`
	// Instance is the optional container name, that allows you to request logs from a specific function instance
	Instance string `json:"instance"`
	// Since is the optional datetime value to start the logs from
	Since *time.Time `json:"since"`
	// Tail sets the maximum number of log messages to return, <=0 means unlimited
	Tail int `json:"tail"`
	// Follow is allows the user to request a stream of logs until the timeout
	Follow bool `json:"follow"`
}

Request is the query to return the function logs.

func (Request) String

func (r Request) String() string

String implements that Stringer interface and prints the log Request in a consistent way that allows you to safely compare if two requests have the same value.

type Requester

type Requester interface {
	// Query submits a log request to the actual logging system.
	Query(context.Context, Request) (<-chan Message, error)
}

Requester submits queries the logging system. This will be passed to the log handler constructor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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