* Ad hoc per-package logging. When Nix performs a derivation, it now
writes stdout/stderr of the builder to ${prefix}/var/log/nix/x, where x is the file name of the derivation expression, e.g., /nix/var/log/nix/54256391624be04fcb426048ae3ea0a4-d-pan-0.14.2.nix Note that consecutive builds of the same expression overwrite, rather than append to, existing log files.
This commit is contained in:
parent
143427f90b
commit
9d95aafe8c
|
@ -16,14 +16,14 @@ static string pathNullDevice = "/dev/null";
|
||||||
|
|
||||||
/* Run a program. */
|
/* Run a program. */
|
||||||
void runProgram(const string & program,
|
void runProgram(const string & program,
|
||||||
const Strings & args, const Environment & env)
|
const Strings & args, const Environment & env,
|
||||||
|
const string & logFileName)
|
||||||
{
|
{
|
||||||
/* Create a log file. */
|
/* Create a log file. */
|
||||||
string logFileName = nixLogDir + "/run.log";
|
|
||||||
string logCommand =
|
string logCommand =
|
||||||
verbosity >= lvlDebug
|
verbosity >= lvlDebug
|
||||||
? "tee -a " + logFileName + " >&2"
|
? "tee " + logFileName + " >&2"
|
||||||
: "cat >> " + logFileName;
|
: "cat > " + logFileName;
|
||||||
/* !!! auto-pclose on exit */
|
/* !!! auto-pclose on exit */
|
||||||
FILE * logFile = popen(logCommand.c_str(), "w"); /* !!! escaping */
|
FILE * logFile = popen(logCommand.c_str(), "w"); /* !!! escaping */
|
||||||
if (!logFile)
|
if (!logFile)
|
||||||
|
|
|
@ -15,7 +15,8 @@ typedef map<string, string> Environment;
|
||||||
|
|
||||||
/* Run a program. */
|
/* Run a program. */
|
||||||
void runProgram(const string & program,
|
void runProgram(const string & program,
|
||||||
const Strings & args, const Environment & env);
|
const Strings & args, const Environment & env,
|
||||||
|
const string & logFileName);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__EXEC_H */
|
#endif /* !__EXEC_H */
|
||||||
|
|
|
@ -164,7 +164,8 @@ Path normaliseNixExpr(const Path & _nePath, PathSet pending)
|
||||||
|
|
||||||
/* Run the builder. */
|
/* Run the builder. */
|
||||||
msg(lvlChatty, format("building..."));
|
msg(lvlChatty, format("building..."));
|
||||||
runProgram(ne.derivation.builder, ne.derivation.args, env);
|
runProgram(ne.derivation.builder, ne.derivation.args, env,
|
||||||
|
nixLogDir + "/" + baseNameOf(nePath));
|
||||||
msg(lvlChatty, format("build completed"));
|
msg(lvlChatty, format("build completed"));
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue