Documentation

Overview

    Package slogtest contains the slogger for use with Go's testing package.

    If imported, then all logs that go through the stdlib's default logger will go through slog.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Debug

    func Debug(t testing.TB, msg string, fields ...slog.Field)

      Debug logs the given msg and fields to t via t.Log at the debug level.

      func Error

      func Error(t testing.TB, msg string, fields ...slog.Field)

        Error logs the given msg and fields to t via t.Error at the error level.

        func Fatal

        func Fatal(t testing.TB, msg string, fields ...slog.Field)

          Fatal logs the given msg and fields to t via t.Fatal at the fatal level.

          func Info

          func Info(t testing.TB, msg string, fields ...slog.Field)

            Info logs the given msg and fields to t via t.Log at the info level.

            func Make

            func Make(tb testing.TB, opts *Options) slog.SinkContext

              Make creates a logger that writes logs to tb in a human readable format.

              Types

              type Options

              type Options struct {
              	// IgnoreErrors causes the test logger to not fatal the test
              	// on Fatal and not error the test on Error or Critical.
              	IgnoreErrors bool
              }

                Options represents the options for the logger returned by Make.

                Source Files

                Directories

                Path Synopsis
                Package assert is a helper package for test assertions.
                Package assert is a helper package for test assertions.