Help us shape the future of Go! Take the 2026 Go Developer Survey

projectlog

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package projectlog searches, tails and counts a project's runtime logs across its functions, frontends or databases, with the filters the log routes share.

Index

Constants

View Source
const (
	TypeFunction = "function"
	TypeFrontend = "frontend"
	TypeDatabase = "database"
)

Resource types a log read selects, as the API names them.

View Source
const (
	KindStandard = "standard"
	KindDurable  = "durable"
)

Function kinds a function log read can narrow to.

View Source
const MaxPage = 1000

MaxPage is the API's largest log search page, and the most recent logs a tail can start with.

Variables

View Source
var Levels = []string{"trace", "debug", "info", "warn", "error", "fatal"}

Levels are the log levels the API records, lowest first.

Functions

func BuildQuery

func BuildQuery(filters Filters) string

BuildQuery joins the free-text query and the field filters into one log query. Terms are ANDed, and the free-text query is parenthesized so an OR in it cannot swallow a filter.

Types

type Filters

type Filters struct {
	// Query is a log query, such as `timeout OR "connection reset"`.
	Query      string
	Level      string
	Region     string
	Invocation string
	Start      *time.Time
	End        *time.Time
}

Filters narrow a read the same way on every log route.

type Selector

type Selector struct {
	Type string
	// Kind narrows functions to standard or durable ones; empty reads both.
	Kind string
	// Names are resource names or IDs. Databases are named only by name.
	Names []string
}

Selector chooses whose logs to read: every resource of one type, or the named ones.

type Service

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

Service reads the current project's logs.

func NewService

func NewService(deps cliruntime.Deps) Service

NewService returns a project log service.

func (Service) Activity

func (s Service) Activity(ctx context.Context, query api.LogQuery, buckets int) (*apiclient.LogActivityResponse, error)

Activity returns bucketed counts of matching logs.

func (Service) Each

func (s Service) Each(ctx context.Context, query api.LogQuery, limit int, visit func([]apiclient.LogSearchEvent) error) (bool, error)

Each pages through matching logs, newest first, handing each page to visit until limit logs have been visited or none remain. It reports whether more may match than were visited.

A page can hold fewer logs than asked for, or none, while more remain, so paging stops on the API's has_more rather than on a short page.

func (Service) Query

func (s Service) Query(ctx context.Context, selector Selector, filters Filters) (api.LogQuery, error)

Query checks the selector and filters, resolves each name to its ID, and returns the read they describe.

func (Service) Search

func (s Service) Search(ctx context.Context, query api.LogQuery, limit int, cursor string) (*apiclient.LogSearchResponse, error)

Search returns one page of matching logs, newest first.

func (Service) Stream

func (s Service) Stream(ctx context.Context, query api.LogQuery, limit int, lastEventID string) (*api.ProjectLogStream, error)

Stream live-tails matching logs, resuming after lastEventID when it is set.

Jump to

Keyboard shortcuts

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