summary

package
v1.167.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package summary provides loggers for producing concise human-readable summaries rather than full diagnostic log streams.

Unlike regular streaming loggers, summary loggers target destinations that accumulate a rendered summary. This is useful when a concise human-readable report should be presented separately from raw logs, for example in CI systems, automated reports, or workflow dashboards.

The package writes plain strings, so the destination can render the content directly or interpret it using Markdown. This is helpful for status sections, bullet lists, check results, and short report content that should stay easy to scan while remaining separate from verbose diagnostic output.

References:

Index

Constants

View Source
const (
	// GitHubStepSummaryEnvironmentVariable is the environment variable pointing to
	// the current GitHub Actions step summary file.
	GitHubStepSummaryEnvironmentVariable = "GITHUB_STEP_SUMMARY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSummaryLogger

type FileSummaryLogger struct {
	ISummaryLogger
}

FileSummaryLogger writes summary content to a plain-text file sink.

The file content may still contain Markdown syntax; the logger itself only treats it as plain text.

func NewFileSummaryLogger

func NewFileSummaryLogger(path string, loggerSource string) (logger *FileSummaryLogger, err error)

NewFileSummaryLogger creates a summary logger that writes summary entries to path as plain text.

This is useful in CI and reporting flows where the final summary should be written to a known file for later display or collection.

func NewGitHubSummaryLogger

func NewGitHubSummaryLogger(loggerSource string) (logger *FileSummaryLogger, err error)

NewGitHubSummaryLogger creates a summary logger backed by the file path stored in `GITHUB_STEP_SUMMARY`.

GitHub renders that file as Markdown on the workflow summary page, which makes this helper useful for publishing compact CI job summaries alongside ordinary logs.

Reference:

type ISummaryLogger

type ISummaryLogger interface {
	baselogs.Loggers
	// WriteString appends summary content and ensures it ends with a newline.
	//
	// Embedded trailing CR/LF characters are trimmed so each call writes one
	// logical summary line.
	WriteString(content string) error
	// WriteStringF appends formatted summary content and ensures it ends with a
	// newline.
	//
	// It follows the same newline handling as [ISummaryLogger.WriteString].
	WriteStringF(format string, values ...any) error
}

ISummaryLogger extends [logs.Loggers] with operations for writing human-readable summary content.

The summary API writes plain strings. Implementations may render or persist those strings in richer formats such as Markdown.

type InMemorySummaryLogger

type InMemorySummaryLogger struct {
	SummaryLogger
}

InMemorySummaryLogger stores summary content in memory.

func NewInMemorySummaryLogger

func NewInMemorySummaryLogger(loggerSource string) (logger *InMemorySummaryLogger, err error)

NewInMemorySummaryLogger creates an in-memory summary logger backed by the repository's plain string logger.

This is useful in tests and in flows that need to build up summary content before deciding where to render or persist it.

func (*InMemorySummaryLogger) GetSummary

func (s *InMemorySummaryLogger) GetSummary() string

GetSummary returns the accumulated summary content.

type SummaryLogger

type SummaryLogger struct {
	baselogs.Loggers
}

SummaryLogger adapts a regular [logs.Loggers] implementation to the ISummaryLogger interface.

It normalises each summary write to a single trailing newline before sending the content through the wrapped logger.

func NewSummaryLogger

func NewSummaryLogger(baseLogger baselogs.Loggers) (logger *SummaryLogger)

NewSummaryLogger creates a summary logger backed by baseLogger.

func (*SummaryLogger) WriteString

func (b *SummaryLogger) WriteString(content string) error

WriteString appends summary content and ensures it ends with a newline.

func (*SummaryLogger) WriteStringF

func (b *SummaryLogger) WriteStringF(format string, values ...any) error

WriteStringF appends formatted summary content and ensures it ends with a newline.

Any trailing CR/LF characters already present in the formatted text are trimmed so the wrapped logger emits one logical summary line per call.

Jump to

Keyboard shortcuts

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