Documentation
¶
Overview ¶
Package logging owns the process's rotating diagnostics. An entry point installs it once; a Node never installs a handler. Records contain identifiers and lifecycle metadata, never operation payloads.
Index ¶
- Constants
- Variables
- func CurrentFile() (string, error)
- func Directory() string
- func Emit(level slog.Level, attrs ...slog.Attr)
- func Install(profile, application string) (func(), error)
- func Retain(profile string) error
- func SetReport(receive func(slog.Level, Fields))
- func SetReportWithTrace(receive func(slog.Level, Fields, []uintptr))
- func StackAttr(err error) slog.Attr
- func StackPCs(err error) []uintptr
- func Tail(path string) ([]byte, error)
- func ValidReportRef(s string) bool
- func WrapStack(err error) error
- type Fields
- type Span
Constants ¶
const ( Begin = "begin" Admitted = "admitted" Completed = "completed" Failed = "failed" Cancelled = "cancelled" Interrupted = "interrupted" )
Phases of an observed operation.
const Target = "sailry"
Target is the message of every record this package owns. The handler writes those to the file and passes all others to the handler it replaced.
Variables ¶
ErrUnavailable reports that logging could not be installed.
Functions ¶
func CurrentFile ¶
CurrentFile is the active file, or the latest earlier daily file before the first record. It is "" when there is none.
func Directory ¶
func Directory() string
Directory is the profile's logs directory, "" before Install.
func Install ¶
Install starts the application's log under the profile at logs/<application>/current.log and makes it the slog default. application is "desktop" or "host". The returned function ends it after the Node has stopped. A second installation in one process fails.
func Retain ¶
Retain retires earlier daily files. A Node calls it only after it owns the profile, so a rejected second start cannot retire a running process's file. Other files, directories and links in the directory remain untouched.
func SetReport ¶
SetReport names the receiver of warning and error records, nil for none. It is called on the logging goroutine and must not block.
func SetReportWithTrace ¶
SetReportWithTrace names the receiver of warning and error records along with any origin stack PCs attached to the record, nil for none. It is called on the logging goroutine and must not block.
func StackAttr ¶
StackAttr returns an internal slog attribute carrying err's origin stack counters, or an empty attribute when err carries none.
func Tail ¶
Tail is the diagnostics attachment: the last records of the active file's final mebibyte, each reduced by Remote, one JSON object per line. An empty path gives an empty attachment.
func ValidReportRef ¶ added in v0.2.5
ValidReportRef accepts only canonical, random v4 references. In particular a request's timestamped v7 identifier is not a report reference.
Types ¶
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span observes one operation. It never cancels or replays the work it describes.
func NewBackground ¶
NewBackground observes a package's read at debug level, omitting a fast success.
func NewQuery ¶
NewQuery observes an ordinary read: only a slow completion, a failure or an uncertain outcome is recorded.
func (*Span) Finish ¶
Finish records the outcome once. code is "" for success; warn lowers an expected failure to a warning.