stdenv: only log hooks if $NIX_DEBUG >= 4#331560
Conversation
emilazy
left a comment
There was a problem hiding this comment.
A little nit. Don’t feel like building stdenv to test this out, but the basic temporary compromise seems sound to me, even if it will probably satisfy nobody.
I do think that this should probably be a higher value than 2 so that we have room to add things that are less noisy than this, but it doesn’t really matter that much.
0f6c60c to
1938735
Compare
1938735 to
c48d19f
Compare
c48d19f to
a7363f6
Compare
a7363f6 to
916aedb
Compare
|
To test this, btw, I use |
916aedb to
2c93603
Compare
Nix filters out messages with level ≥ 4 by default as of this commit.
2c93603 to
d8fbb16
Compare
| # $NIX_DEBUG must be a documented integer level, if set, so we can use it safely as an integer. | ||
| # See the `Verbosity` enum in the Nix source for these levels. | ||
| if ! [[ -z ${NIX_DEBUG-} || $NIX_DEBUG == [0-7] ]]; then | ||
| printf 'The `NIX_DEBUG` environment variable has an unexpected value: %s\n' "${NIX_DEBUG}" |
There was a problem hiding this comment.
I think it’s OK to use echo in this case since we know that the argument will not be interpreted as a flag.
| printf 'The `NIX_DEBUG` environment variable has an unexpected value: %s\n' "${NIX_DEBUG}" | |
| echo "The `NIX_DEBUG` environment variable has an unexpected value: ${NIX_DEBUG@Q}" |
Note: ${parameter@Q} quotes the string, similar to printf %q. See https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
marcusramberg
left a comment
There was a problem hiding this comment.
This change looks good to me. Ran the tests over night and it seems to work well in practice as well, although I didn't test with debugging enabled. I agree with keeping it simple with the cost of some duplication. Would be very nice to get this merged as the current logging of hooks seems to the be causing some real world problems.
|
Not sure if this is an issue with the logging infra or nix, but I'm noticing some issues in |
|
Ah ok, thanks. Staging is not on master yet and my working tree is normally not staging. So probably with a next staging merge it'll be good. |
|
@Mindavi note that the PR is in staging-next already if you need it urgently. |
|
No worries, not in a rush 🙂 |
Motivation for change
Make the logging output by default from the stdenv less verbose.
Description of changes
Sourcing setup hook *default hook*spam in writers/trivial builders #328229Due to feedback about the amount of logging output in the above issue, this PR moves the hook logging added in PRs #290081 and #310387 under
$NIX_DEBUG, specifically at "talkative" level.As a part of this commit,
nixLogis no more, replaced with these eight available logging functions:nixErrorLog(logs at $NIX_DEBUG>=0 level, which is always)nixWarnLog(logs at $NIX_DEBUG>=1 level)nixNoticeLog(logs at $NIX_DEBUG>=2 level)nixInfoLog(logs at $NIX_DEBUG>=3 level)nixTalkativeLog(logs at $NIX_DEBUG>=4 level)nixChattyLog(logs at $NIX_DEBUG>=5 level)nixDebugLog(logs at $NIX_DEBUG>=6 level)nixVomitLog(logs at $NIX_DEBUG>=7 level)All of these names are from the Nix source code.
Setting
$NIX_DEBUGis left as an exercise for the reader.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)