Logy|Docs

Typed loggers

Use logy.Of when a Go type should define the logger boundary.

logy.Of creates a logger from a Go type. Use it when a component, client, or service type is the clearest name to show in log output.

client.go
type PaymentClient struct {
	endpoint string
}

func (c *PaymentClient) Charge(userID string) {
	log := logy.Of[PaymentClient]()

	log.Info("charging user {}", userID)
}

Typed loggers are helpful when many packages contain similar roles, or when a type name is easier to search than a package path.

Prefer logy.Get for normal package logging. Reach for logy.Of when the type name carries the operational meaning.