logging

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logging is the service's log: JSON lines on one stream, in the keys Cloud Logging reads, held to the table of events in events.go.

Every line goes through guard, which writes only what the table allows. So the rule that the log carries no direct identifier, IP address, work, reading or hint text (R09 spec; privacy 4 spec) does not rest on each line's author remembering it: a field the table does not give the event is dropped and counted, and an event the table does not know loses its message. The libraries in the process — tutor, module-kit and the rest — are handed this same *slog.Logger, and their lines pass the same guard.

Index

Constants

View Source
const (
	// EventStartup is the line that says a revision has started, and which
	// build it runs. The delivery finds a revision's release by it.
	EventStartup = "startup"
	// EventStopping is the line that says a stop was asked for.
	EventStopping = "stopping"
	// EventStopped is the line that says the server has drained.
	EventStopped = "stopped"
	// EventShutdown is the last line of a process that stopped as asked.
	EventShutdown = "shutdown"
	// EventFailure is a failure nobody asked for, at a moment of the closed set
	// the field moment names.
	EventFailure = "failure"
	// EventPanic is a panic a handler raised and the server recovered.
	EventPanic = "panic"
	// EventMigrated is the line that says the migrations of a database ran: how many
	// it applied, the version the schema is at, and, for the rights', whether it
	// made the store and wrote the model.
	EventMigrated = "migrated"
	// EventRequest is the line of a request of the protocol: its method, its code,
	// the cause of a refusal, the class of a refused token, how long it ran and,
	// when it failed, the kind of the failure — never its body, headers, address
	// or an ID (R18, R33). The path of a Connect GET holds the message, so the
	// method is written, not the path.
	EventRequest = "request"
)

The events of the service's own lines.

View Source
const (
	FieldVersion       = "version"
	FieldCommit        = "commit"
	FieldDate          = "date"
	FieldPort          = "port"
	FieldDeployed      = "deployed"
	FieldStarted       = "started"
	FieldCutShort      = "cut_short"
	FieldMoment        = "moment"
	FieldErrorKind     = "error_kind"
	FieldPanicKind     = "panic_kind"
	FieldApplied       = "applied"
	FieldSchemaVersion = "schema_version"
	FieldDatabase      = "database"
	FieldStoreCreated  = "store_created"
	FieldModelWritten  = "model_written"
	FieldMethod        = "method"
	FieldCode          = "code"
	FieldCause         = "cause"
	FieldTokenClass    = "token_class"
	FieldDurationMS    = "duration_ms"
)

The fields.

View Source
const (
	MomentStartup  = "startup"
	MomentServe    = "serve"
	MomentShutdown = "shutdown"
	MomentMigrate  = "migrate"
	MomentInvite   = "invite"
)

The moments of a failure: the value set of FieldMoment.

View Source
const (
	DatabaseAPI     = "api"
	DatabaseOpenFGA = "openfga"
)

The databases api migrates: the value set of FieldDatabase.

Variables

View Source
var Codes = []string{
	"ok", "canceled", "unknown", "invalid_argument", "deadline_exceeded", "not_found",
	"already_exists", "permission_denied", "resource_exhausted", "failed_precondition",
	"aborted", "out_of_range", "unimplemented", "internal", "unavailable", "data_loss",
	"unauthenticated",
}

Codes is the value set of FieldCode: Connect's codes in Connect's words, and ok for a request that was not refused.

View Source
var TokenClasses = []string{"expired", "invalid", "revoked", "no_user", "disabled", "failed"}

TokenClasses is the value set of FieldTokenClass: the classes of a refused token, in authn's words (R20, R32).

Functions

func New

func New(w io.Writer, level slog.Leveler) *slog.Logger

New is the log of the process, writing to w the lines at level and above.

Types

type Kind

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

Kind names what an error or a panic is, and none of what it carries: its text may hold a path, an address, a value from a request. Only ErrorKind and PanicKind make one, and the table accepts no other value for the fields error_kind and panic_kind.

func ErrorKind

func ErrorKind(err error) Kind

ErrorKind names an error by its chain, outermost first: the type of each link, a sentinel of the standard library by its name, and an errno of the system in the system's own words, which hold no data. The text of any other link is not written, since an error made by fmt.Errorf holds whatever its author formatted into it.

func PanicKind

func PanicKind(recovered any) Kind

PanicKind names what a panic was raised with. A fault of the Go runtime is put in the runtime's own words, found inside whatever wrapped it, because those words hold types and numbers and no data. Anything else is a value of ours or a library's, which may hold a task, an answer or an image, so only its type is written.

func (Kind) LogValue

func (k Kind) LogValue() slog.Value

LogValue is what the log writes: the name.

func (Kind) String

func (k Kind) String() string

String is the kind's name.

Jump to

Keyboard shortcuts

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