Standard library / log/slog

slog.SetLogLoggerLevel()

Set the severity used by the bridge between log and slog; return the previous level. Expected stdout: 'WARN\n'.

Formal Syntax & Structure

go syntaxgo
func SetLogLoggerLevel(level Level) (oldLevel Level)

Parameters & Attributes

NameTypeDescription
levelLevelSeverity of the event or minimum level.

Return Value

(oldLevel Level)

Set the severity used by the bridge between log and slog; return the previous level.

Working Example

Example Snippetgo
package main
import (  "fmt"  "log/slog")
func main() {  old := slog.SetLogLoggerLevel(slog.LevelWarn)  defer slog.SetLogLoggerLevel(old)  fmt.Println(slog.SetLogLoggerLevel(slog.LevelInfo))}
Go Reference