audit-go/log/slog_test.go
2024-10-30 10:32:07 +00:00

43 lines
941 B
Go

package log
import (
"errors"
"log/slog"
"testing"
)
func Test_SlogLogger(t *testing.T) {
UseSlogAuditLogger(slog.Default())
t.Run("debug", func(t *testing.T) {
AuditLogger.Debug("debug message")
})
t.Run("debug with error details", func(t *testing.T) {
AuditLogger.Debug("debug message", errors.New("custom error"))
})
t.Run("info", func(t *testing.T) {
AuditLogger.Info("info message")
})
t.Run("info with error details", func(t *testing.T) {
AuditLogger.Info("info message", errors.New("custom error"))
})
t.Run("warn", func(t *testing.T) {
AuditLogger.Warn("warn message")
})
t.Run("warn with error details", func(t *testing.T) {
AuditLogger.Warn("warn message", errors.New("custom error"))
})
t.Run("error", func(t *testing.T) {
AuditLogger.Error("error message")
})
t.Run("error with error details", func(t *testing.T) {
AuditLogger.Error("error message", errors.New("custom error"))
})
}