Standard library / log/slog

slog.Record.NumAttrs()

Return the number of attributes in the record. Expected stdout: '1\n'.

Formal Syntax & Structure

go syntaxgo
func (r Record) NumAttrs() int

Return Value

int

Return the number of attributes in the record.

Working Example

Example Snippetgo
package main
import (  "fmt"  "log/slog"  "time")
func main() {  r := slog.NewRecord(time.Time{}, slog.LevelInfo, "ready", 0)  r.Add("n", 2)  fmt.Println(r.NumAttrs())}
Go Reference