stern

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const TimestampFormatDefault = "2006-01-02T15:04:05.000000000Z07:00"

RFC3339Nano with trailing zeros

View Source
const TimestampFormatShort = "01-02 15:04:05"

time.DateTime without year

Variables

This section is empty.

Functions

func ContainerGenerator

func ContainerGenerator(ctx context.Context, config *DockerConfig, client *dockerclient.Client) (iter.Seq[types.ContainerJSON], error)

func FilteredContainerGenerator

func FilteredContainerGenerator(ctx context.Context, config *DockerConfig, client *dockerclient.Client, filter *dockerTargetFilter) (iter.Seq[*DockerTarget], error)

func RunDocker

func RunDocker(ctx context.Context, client *dockerclient.Client, config *DockerConfig) error

func SetColorList

func SetColorList(composeColors, containerColors []string) error

func WatchDockers

func WatchDockers(ctx context.Context, config *DockerConfig, filter *dockerTargetFilter, client *dockerclient.Client) (chan *DockerTarget, error)

Types

type DockerConfig

type DockerConfig struct {
	Timestamps            bool
	TimestampFormat       string
	Location              *time.Location
	Label                 []string
	ContainerQuery        []*regexp.Regexp
	ExcludeContainerQuery []*regexp.Regexp
	ComposeProjectQuery   []*regexp.Regexp
	Exclude               []*regexp.Regexp
	ImageQuery            []*regexp.Regexp
	Include               []*regexp.Regexp
	Highlight             []*regexp.Regexp
	Since                 time.Duration
	TailLines             int64
	Template              *template.Template
	Follow                bool
	OnlyLogLines          bool
	MaxLogRequests        int
	Stdin                 bool

	Out    io.Writer
	ErrOut io.Writer
}

Config contains the config for tailfin

type DockerTail

type DockerTail struct {
	ContainerId    string
	ContainerName  string
	ComposeProject string
	Tty            bool

	Options *TailOptions
	// contains filtered or unexported fields
}

func NewDockerTail

func NewDockerTail(
	client *dockerclient.Client,
	containerId string,
	containerName string,
	composeProject string,
	tty bool,
	tmpl *template.Template,
	out, errOut io.Writer,
	options *TailOptions,
) *DockerTail

func (*DockerTail) Close

func (t *DockerTail) Close()

func (*DockerTail) GetResumeRequest added in v0.1.1

func (t *DockerTail) GetResumeRequest() *ResumeRequest

func (*DockerTail) Print

func (t *DockerTail) Print(msg string)

func (*DockerTail) Resume added in v0.1.1

func (t *DockerTail) Resume(ctx context.Context, resumeRequest *ResumeRequest) error

func (*DockerTail) Start

func (t *DockerTail) Start(ctx context.Context) error

type DockerTarget

type DockerTarget struct {
	Id             string
	Name           string
	ComposeProject string
	Tty            bool
	StartedAt      time.Time
	ResumeRequest  *ResumeRequest
}

type FileTail

type FileTail struct {
	Options *TailOptions
	// contains filtered or unexported fields
}

func NewFileTail

func NewFileTail(tmpl *template.Template, in io.Reader, out, errOut io.Writer, options *TailOptions) *FileTail

NewFileTail returns a new tail of the input reader

func (*FileTail) ConsumeReader

func (t *FileTail) ConsumeReader(reader *bufio.Reader) error

ConsumeReader reads the data from the reader and writes into the out writer.

func (*FileTail) Print

func (t *FileTail) Print(msg string)

Print prints a color coded log message

func (*FileTail) Start

func (t *FileTail) Start() error

Start starts tailing

type Log

type Log struct {
	// Message is the log message itself
	Message string `json:"message"`

	ContainerName string `json:"container"`

	ComposeProject string `json:"compose"`

	ComposeColor   *color.Color `json:"-"`
	ContainerColor *color.Color `json:"-"`
}

Log is the object which will be used together with the template to generate the output.

type ResumeRequest

type ResumeRequest struct {
	Timestamp   string // RFC3339 timestamp (not RFC3339Nano)
	LinesToSkip int    // the number of lines to skip during this timestamp
}

type TailOptions

type TailOptions struct {
	Timestamps      bool
	TimestampFormat string
	Location        *time.Location

	DockerSinceTime string
	Exclude         []*regexp.Regexp
	Include         []*regexp.Regexp
	Highlight       []*regexp.Regexp
	DockerTailLines string
	Follow          bool
	OnlyLogLines    bool
	// contains filtered or unexported fields
}

func (TailOptions) HighlightMatchedString

func (o TailOptions) HighlightMatchedString(msg string) string

func (TailOptions) IsExclude

func (o TailOptions) IsExclude(msg string) bool

func (TailOptions) IsInclude

func (o TailOptions) IsInclude(msg string) bool

func (TailOptions) UpdateTimezoneAndFormat

func (o TailOptions) UpdateTimezoneAndFormat(timestamp string) (string, error)

Jump to

Keyboard shortcuts

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