Standard library / log/slog
slog.New()
Construct a logger with the supplied non-nil handler. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func New(h Handler) *LoggerParameters & Attributes
| Name | Type | Description |
|---|---|---|
| h | Handler | Handler processing records. |
Return Value
*Logger
Construct a logger with the supplied non-nil handler.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "log/slog")
func main() { var b bytes.Buffer l := slog.New(slog.NewTextHandler(&b, nil)) fmt.Println(l.Handler() != nil)}