forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1212b1f
JSONLogger: Log to a file descriptor instead of another Logger
edolstra 8ef94c1
Add a structured log message for FOD hash mismatches
edolstra 1f702cd
Allow separate JSON logging
edolstra 2972e73
Turn NIX_LOG_FILE into a setting
edolstra 29a9e63
Remove "@nix" prefix from json-log-path output
edolstra 1efccf3
JSONLogger: Acquire a lock to prevent log messages from clobbering ea…
edolstra d9730fc
Fix fd check
edolstra 220000d
makeJSONLogger(): Support logging to a Unix domain socket
edolstra 2a2af3f
Logger::result(): Support logging arbitrary JSON objects
edolstra c515bc6
Provide a structured JSON serialisation of hashes
edolstra 762114b
Log BuildResult
edolstra fd0d824
Don't use DerivedPath::toJSON()
edolstra 8674792
Make the JSON logger more robust
edolstra c32441f
Remove redundant quotes
edolstra bc3a847
BuildResult: Serialize builtOutputs
edolstra 502f027
nix daemon: Respect json-log-path and re-open for every connection
edolstra c8692b3
Merge remote-tracking branch 'detsys/detsys-main' into logger-improve…
edolstra 17d0810
Cleanup
edolstra eca002d
Don't segfault if we can't create the JSON logger
edolstra 37f3b25
makeTeeLogger(): Distinguish between main and extra loggers
edolstra f80f7e0
Abort if we cannot create TeeLogger
edolstra 9e6c999
Add release note
edolstra 10f9b2f
Set release date
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,49 @@ | ||
#include "build-result.hh" | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace nix { | ||
|
||
bool BuildResult::operator==(const BuildResult &) const noexcept = default; | ||
std::strong_ordering BuildResult::operator<=>(const BuildResult &) const noexcept = default; | ||
|
||
void to_json(nlohmann::json & json, const BuildResult & buildResult) | ||
{ | ||
json = nlohmann::json::object(); | ||
json["status"] = BuildResult::statusToString(buildResult.status); | ||
if (buildResult.errorMsg != "") | ||
json["errorMsg"] = buildResult.errorMsg; | ||
if (buildResult.timesBuilt) | ||
json["timesBuilt"] = buildResult.timesBuilt; | ||
if (buildResult.isNonDeterministic) | ||
json["isNonDeterministic"] = buildResult.isNonDeterministic; | ||
if (buildResult.startTime) | ||
json["startTime"] = buildResult.startTime; | ||
if (buildResult.stopTime) | ||
json["stopTime"] = buildResult.stopTime; | ||
} | ||
|
||
void to_json(nlohmann::json & json, const KeyedBuildResult & buildResult) | ||
{ | ||
to_json(json, (const BuildResult &) buildResult); | ||
auto path = nlohmann::json::object(); | ||
std::visit( | ||
overloaded{ | ||
[&](const DerivedPathOpaque & opaque) { path["opaque"] = opaque.path.to_string(); }, | ||
[&](const DerivedPathBuilt & drv) { | ||
path["drvPath"] = drv.drvPath->getBaseStorePath().to_string(); | ||
path["outputs"] = drv.outputs; | ||
auto outputs = nlohmann::json::object(); | ||
for (auto & [name, output] : buildResult.builtOutputs) | ||
outputs[name] = { | ||
{"path", output.outPath.to_string()}, | ||
{"signatures", output.signatures}, | ||
}; | ||
json["builtOutputs"] = std::move(outputs); | ||
}, | ||
}, | ||
buildResult.path.raw()); | ||
json["path"] = std::move(path); | ||
} | ||
|
||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.