Standard library / log/slog
slog.LevelVar.MarshalText()
Encode the current level as text. Expected stdout: 'INFO\n'.
Formal Syntax & Structure
go syntaxgo
func (v *LevelVar) MarshalText() ([]byte, error)Return Value
([]byte, error)
Encode the current level as 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; b, e := l.MarshalText(); check(e); fmt.Println(string(b)) }