slogtest

package
v2.0.2-0...-0d99925 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 7 Imported by: 0

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.

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL