feat: introduce warnings/traces fields and optional stderr prefix of attribute path#409
Draft
ConnorBaker wants to merge 3 commits intoNixOS:mainfrom
Draft
feat: introduce warnings/traces fields and optional stderr prefix of attribute path#409ConnorBaker wants to merge 3 commits intoNixOS:mainfrom
ConnorBaker wants to merge 3 commits intoNixOS:mainfrom
Conversation
Worker subprocesses now wrap `nix::logger` with a `PrefixLogger` that prepends `attrPath:` to all log messages while an attribute is being evaluated. Direct stderr writes in the catch blocks are similarly prefixed so that every warning, trace, and error on stderr is attributable to the attribute path that caused it. Uses std::format for prefix formatting, a Finally RAII guard for exception-safe attrPath cleanup, and removes unused getAttrPath(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PrefixLogger now buffers log messages during evaluation. Messages starting with "trace:" (from builtins.trace) go to a traces buffer; all other messages (from builtins.warn, logWarning, etc.) go to a warnings buffer. After each attribute is evaluated, the buffers are drained into the Response and serialized as optional JSON fields (omitted when empty). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The stderr prefix (attrPath: ...) is now opt-in via --log-attr-prefix to avoid breaking scripts that parse stderr output. Without the flag, stderr output is unchanged from the previous behavior. The JSON traces/warnings fields are always populated regardless of the flag, since they are structured data for machine consumption. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5776dad to 20438ed Compare Author
| @Mic92 how does this approach compare with the one you've got in #396? I see both introduce a new logger, but yours additionally introduces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caution
This is a work in progress and entirely vibe-coded.
The goal of the PR is to make it easier to analyze
nix-eval-jobslogs for both people (i.e., by providing attribution of warnings/traces to the attribute paths which created them) and scripts (i.e., adding warnings/traces fields to the JSON objects being streamed out).Summary
nix::loggerwith aPrefixLoggerdecorator that can prepend attrPath: to all stderr log lines during evaluation, making interleaved multi-worker output attributable--log-attr-prefixto avoid breaking existing scripts that parse stderrbuiltins.traceandbuiltins.warn outputthat was previously only available on stderr