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 ¶
const ( FormatMSBuildBinlog = "msbuild-binlog" FormatMSBuildText = "msbuild-text" FormatVCBuildHTML = "vcbuild-html" ToolMSBuild = "msbuild" ToolVCBuild = "vcbuild" SeverityWarning = "warning" SeverityError = "error" ResultSucceeded = "succeeded" ResultFailed = "failed" )
Variables ¶
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.
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 ¶
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.