Standard library / log/slog

slog.NewRecord()

Create a structured log record with explicit time, level, message and program counter. Expected stdout: 'INFO ready\n'.

Formal Syntax & Structure

go syntaxgo
func NewRecord(t time.Time, level Level, msg string, pc uintptr) Record

Parameters & Attributes

NameTypeDescription
ttime.TimeInput to the operation as described above.
levelLevelSeverity of the event or minimum level.
msgstringHuman-readable log message.
pcuintptrInput to the operation as described above.

Return Value

Record

Create a structured log record with explicit time, level, message and program counter.

Working Example

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