log

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package log provides functionality to interact with the Nine logging API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationQuery added in v1.21.0

func ApplicationQuery(name, project string) string

ApplicationQuery selects the logs of the application name in project, excluding its build logs.

func BuildQuery added in v1.21.0

func BuildQuery(name, project string) string

BuildQuery selects the logs of the build name in project.

func BuildsOfAppQuery added in v1.21.0

func BuildsOfAppQuery(name, project string) string

BuildsOfAppQuery selects the logs of all builds of the application name in project.

func Mode

func Mode(m string) string

Mode translates the mode to lokis terminology.

func NewFake

func NewFake(t *testing.T, expectedTime time.Time, expectedLines ...string) *fake

func Selector added in v1.21.0

func Selector(matchers ...Matcher) string

Selector returns the LogQL stream selector combining all matchers.

func StdOut

func StdOut(mode string) (output.LogOutput, error)

StdOut sets up an stdout log output with the specified mode.

Types

type Client

type Client struct {
	logclient.Client
	StdOut output.LogOutput
	// contains filtered or unexported fields
}

func NewClient

func NewClient(address string, tokenFunc tokenFunc, orgID string, insecure bool) (*Client, error)

NewClient returns a new log API client.

func (*Client) LiveTailQueryConn added in v1.7.6

func (c *Client) LiveTailQueryConn(ctx context.Context, queryStr string, delayFor time.Duration, limit int, start time.Time, quiet bool) (*websocket.Conn, error)

LiveTailQueryConn does a live tailing with a specific query.

func (*Client) QueryRange

func (c *Client) QueryRange(ctx context.Context, out output.LogOutput, q Query) error

QueryRange queries logs within a specific time range and prints the result.

func (*Client) QueryRangeResponse added in v1.7.6

func (c *Client) QueryRangeResponse(ctx context.Context, q Query) (*loghttp.QueryResponse, error)

QueryRangeResponse queries logs within a specific time range and returns the response.

func (*Client) TailQuery

func (c *Client) TailQuery(ctx context.Context, delayFor time.Duration, out output.LogOutput, q Query) error

TailQuery tails logs using the loki websocket endpoint. This has been adapted from https://github.com/grafana/loki/blob/v2.8.2/pkg/logcli/query/tail.go#L22 as it directly prints out messages using builtin log, which we don't want.

type Matcher added in v1.21.0

type Matcher string

Matcher is a single LogQL label matcher such as `app="name"`. Matchers are combined into a stream selector with Selector.

func Equal added in v1.21.0

func Equal(key, value string) Matcher

Equal returns a matcher selecting streams whose label key equals value.

func InProject added in v1.21.0

func InProject(project string) Matcher

InProject returns a matcher selecting the streams of the given project.

func NotEqual added in v1.21.0

func NotEqual(key, value string) Matcher

NotEqual returns a matcher selecting streams whose label key does not equal value.

type Output added in v1.8.4

type Output interface {
	output.LogOutput
	// LineCount returns the amount of lines the output has processed
	LineCount() int
}

func NewOutput added in v1.8.4

func NewOutput(w io.Writer, mode string, noLabels bool, labels ...string) (Output, error)

func NewStdOut added in v1.8.0

func NewStdOut(mode string, noLabels bool, labels ...string) (Output, error)

type Query

type Query struct {
	QueryString string
	Start       time.Time
	End         time.Time
	Limit       int
	Step        time.Duration
	Interval    time.Duration
	Quiet       bool
	Direction   logproto.Direction
}

Jump to

Keyboard shortcuts

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