Standard library / log/slog
slog.LevelVar.UnmarshalText()
Parse and update the current level from text. Expected stdout: 'WARN\n'.
Formal Syntax & Structure
go syntaxgo
func (v *LevelVar) UnmarshalText(data []byte) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| data | []byte | Input to the operation as described above. |
Return Value
error
Parse and update the current level from text.
Working Example
Example Snippetgo
package main
import ( "fmt" "log/slog")
func check(e error) { if e != nil { panic(e) }}
func main() { var l slog.LevelVar; check(l.UnmarshalText([]byte("WARN"))); fmt.Println(l.Level()) }