-
Notifications
You must be signed in to change notification settings - Fork 1
Logger improvements #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Logging to another Logger was kind of nonsensical - it was really just an easy way to get it to write its output to stderr, but that only works if the underlying logger writes to stderr. This change is needed to make it easy to log JSON output somewhere else (like a file or socket).
If the NIX_LOG_FILE environment variable is set, Nix will write JSON log messages to that file in addition to the regular logger (e.g. the progress bar).
It doesn't work on unrealized paths.
We now ignore connection / write errors.
We don't want to inherit the parent's JSON logger since then messages from different daemon processes may clobber each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and worked in local testing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you are incrementally expanding the internal-json format with new Message IDs and such. This is a signal for me that the internal-json interface is actually consumed by someone (except for nix-output-monitor and us) somewhere and that we can make some soft assumptions about stability (it's not gonna get ripped out tomorrow), as well as the fact that we won't be changing the internal-json message format anytime soon.
Am I correct in my rough assessment on future path of internal-json?
I had a few discussions with with other contributors due to ergonomic pains in using internal-json, however the PR alleviates some of the pains including one of the most important: locking of the output stream so the log messages don't arrive messed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(without speaking on behalf of Eelco and his plans:) determinate-nixd consumes it, which let us drop the use of the post-build-hook. My intention is for determinate-nixd to be the only consumer of the Nix daemon's log output, since we accept and rebroadcast the events over the determinate-nixd events API.
Since we ship determinate-nixd and nix-daemon in a matched set (they're both at version 3.1.1) we're able to have greater interface flexibility than we would otherwise. To me this means we could change this format more, and in breaking ways. But not without good reason.
I guess what I mean to say is: I don't intend for this format to be a stable API, since that is what the determinate-nixd events API is intended to provide. However, you can probably build against it without too much annoyance or worry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember why we called it internal-json
, probably because we were afraid to commit to stability and it's not documented anywhere. However, it's used between the client and the daemon so it's de facto required to be a stable format.
One thing I don't like about the current format is that message types are integers. They should probably be strings (e.g. "hash-mismatch"
instead of 109
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message types are integers. They should probably be strings
That was also discussed as a change one could make, since we are not using the self-documenting features of json currently. I don't see any problem in doing that change since the internal-json name came across correctly, as long as one makes sure to keep in touch with nix-output-monitor and friends.
I also believe that the internal-json messages passed around between the client and daemon are not part of the nix language behaviour as the name implies and one should be allowed to break older versions with newer daemons and vice versa along those lines, if communicated correctly.
Upstream PRs: |
Motivation
Some logger improvements to allow collecting useful info (especially in CI) such as hash mismatches, derivation/substitution results, etc.
json-log-path
that writes all log messages to the specified path (which can be a Unix domain socket) in addition to the regular output. This is implemented using a newTeeLogger
.BuildResult
of derivation/substitution goals. Example:Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.