Help us shape the future of Go! Take the 2026 Go Developer Survey

buildlog

package
v1.129.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package buildlog extracts the compiler and build diagnostics (warnings and errors) from the logs Microsoft build tools write, and normalizes them into one Chainloop-defined structure that policies evaluate:

  • MSBuild binary logs (-bl), format version 18 or later
  • MSBuild text logs (console or file logger, any verbosity that keeps warnings), possibly several invocations appended to one file
  • Visual C++ build logs (BuildLog.htm, written by vcbuild), UTF-16 HTML
  • a zip or tar archive holding any mix of the above, in any folders, for builds that produce one log per solution or per project. Archives inside it (such as the binary logs zipped per solution) are read one level deep; entries that are not logs are skipped.

The original log is what a material stores; this projection is recomputed from it whenever policies run. It keeps no raw log text: diagnostic-verbosity logs reach hundreds of megabytes, and the policy engine holds its whole input in memory.

Index

Constants

View Source
const (
	FormatMSBuildBinlog = "msbuild-binlog"
	FormatMSBuildText   = "msbuild-text"
	FormatVCBuildHTML   = "vcbuild-html"

	ToolMSBuild = "msbuild"
	ToolVCBuild = "vcbuild"

	SeverityWarning = "warning"
	SeverityError   = "error"

	ResultSucceeded = "succeeded"
	ResultFailed    = "failed"
)

Variables

View Source
var ErrNoBuildLog = errors.New("no build log found")

ErrNoBuildLog is returned when a material holds no recognizable build log: a single file in another format, or an archive with no build log entry.

View Source
var ErrUnsupportedBinlog = errors.New("unsupported MSBuild binary log version")

ErrUnsupportedBinlog is returned for a binary log whose format version this reader cannot decode.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	Warnings int `json:"warnings"`
	Errors   int `json:"errors"`
}

Counts are the totals a log states about itself, such as MSBuild's "N Warning(s)" summary. They let a policy check that every diagnostic the tool reported was parsed.

type Diagnostic

type Diagnostic struct {
	Severity    string `json:"severity"`
	Code        string `json:"code,omitempty"`
	Message     string `json:"message"`
	File        string `json:"file,omitempty"`
	Line        int    `json:"line,omitempty"`
	Column      int    `json:"column,omitempty"`
	Project     string `json:"project,omitempty"`
	Occurrences int    `json:"occurrences"`
	Logs        []int  `json:"logs"`
}

Diagnostic is one distinct warning or error. Repeats of the same diagnostic (a header warning reported once per translation unit including it, or a project built by several solutions) are folded into one entry: Occurrences counts them, and Logs lists the indexes in Report.Logs of the logs they were seen in, so a folded diagnostic can still be traced to each build.

type Log

type Log struct {
	Source   string  `json:"source,omitempty"`
	Solution string  `json:"solution,omitempty"`
	Format   string  `json:"format"`
	Tool     Tool    `json:"tool"`
	Result   string  `json:"result,omitempty"`
	Summary  Summary `json:"summary"`
	Parsed   Counts  `json:"parsed"`
	Reported *Counts `json:"reported,omitempty"`
}

Log describes one build recorded in the material: a binary log, one MSBuild run of a text log (a text log can hold several, one per solution, which then share a Source), or a Visual C++ build log. Source names the archive entry it was read from, and is empty for a single-file material. Solution is the project the build was run for (usually a .sln), when the log records it.

Result is how the build ended, empty when the log does not say (a log cut short). Parsed counts the occurrences read from the log, comparable with the totals it Reported about itself: fewer parsed than reported means warnings the parser could not read.

type Report

type Report struct {
	Tool        Tool         `json:"tool"`
	Logs        []Log        `json:"logs"`
	Skipped     []string     `json:"skipped,omitempty"`
	Summary     Summary      `json:"summary"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

Report is the policy projection of an MSBUILD_LOG material. Skipped lists the archive entries that were not read as logs, so a policy can tell a log that could not be read from a file that is not a log.

func Parse

func Parse(data []byte) (*Report, error)

Parse projects an MSBUILD_LOG material held in memory.

func ParseFile

func ParseFile(p string) (*Report, error)

ParseFile projects an MSBUILD_LOG material on disk, streaming it.

type Summary

type Summary struct {
	Warnings int            `json:"warnings"`
	Errors   int            `json:"errors"`
	ByCode   map[string]int `json:"by_code"`
}

Summary counts distinct diagnostics.

type Tool

type Tool struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

Tool identifies the build tool that wrote a log.

Jump to

Keyboard shortcuts

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