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) RecordParameters & Attributes
| Name | Type | Description |
|---|---|---|
| t | time.Time | Input to the operation as described above. |
| level | Level | Severity of the event or minimum level. |
| msg | string | Human-readable log message. |
| pc | uintptr | Input 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)}