cloudlogging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cloudlogging is the Cloud Logging emulation.

It exists for the one thing you cannot do against a real project locally: assert on what your code logged. A service writes structured entries with WriteLogEntries; a test (or gcloud) reads them back with ListLogEntries and a filter. "When a payment fails, does an ERROR entry carry the order id?" is a real thing to test, and this is where that entry lands.

Index

Constants

View Source
const MaxEntries = 10000

MaxEntries is how many entries are kept. Enough to assert on a test's output, small enough that a loop logging forever cannot exhaust memory.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	loggingpb.UnimplementedLoggingServiceV2Server
	// contains filtered or unexported fields
}

Service holds log entries in memory.

In memory rather than the KV store: logs are append-heavy and read by query, not by key, and a local run keeps few enough that a bounded slice is simpler than a key layout. The bound keeps a chatty service from growing without end.

func New

func New(clk clock.Clock) *Service

New wires a service.

func (*Service) DeleteLog

func (s *Service) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest) (*emptypb.Empty, error)

DeleteLog drops every entry for one log name.

func (*Service) ListLogEntries

ListLogEntries returns matching entries. The default order is oldest first; "timestamp desc" reverses it, which is what a console tail asks for.

func (*Service) ListLogs

ListLogs returns the distinct log names that have entries.

func (*Service) Reset

func (s *Service) Reset(ctx context.Context, project string) error

Reset clears entries for a project, or all of them when project is empty.

func (*Service) WriteLogEntries

WriteLogEntries appends entries, filling the timestamp and id the server stamps. A per-request LogName, Resource or Labels is the default for entries that omit their own, which is how the high-level client writes a batch.

Jump to

Keyboard shortcuts

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