Standard library / testing

testing.B.Log()

Record diagnostic text without marking failure. Passing test and fuzz logs are normally visible with -v; benchmark logging has its own reporting behavior. Expected process exit: 0; output contains ['PASS', 'diagnostic', 'body reached']. Run as a _test.go file using the Go test harness.

Formal Syntax & Structure

go syntaxgo
func (c *B) Log(args ...any)

Parameters & Attributes

NameTypeDescription
args...anyValues to format or log.

Working Example

Example Snippetgo
package main
import (  "fmt"  "testing")
func BenchmarkReference(b *testing.B) { b.Log("diagnostic"); fmt.Println("body reached") }
Go Reference