github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/log/log_test.go (about)

     1  package log
     2  
     3  import (
     4  	"errors"
     5  	"log/slog"
     6  	"testing"
     7  )
     8  
     9  func TestLog(t *testing.T) {
    10  	Debug("debug")
    11  	Info("source", slog.String("a", ""), slog.String("c", "d"))
    12  	Output(0, slog.LevelError, "error")
    13  	IfErr("test", func() error { return errors.New("log if err") })
    14  }
    15  
    16  func TestLogger(t *testing.T) {
    17  	z := NewSLogger(0)
    18  
    19  	z.Info("zzz")
    20  	z.Output(0, slog.LevelInfo, "xxx")
    21  }