mirror of
https://github.com/NixOS/nix
synced 2025-06-29 06:21:14 +02:00
Make the logger customisable
Add a new `--log-format` cli argument to change the format of the logs. The possible values are - raw (the default one for old-style commands) - bar (the default one for new-style commands) - bar-with-logs (equivalent to `--print-build-logs`) - internal-json (the internal machine-readable json format)
This commit is contained in:
parent
d558fb98f6
commit
170e86dff5
12 changed files with 107 additions and 13 deletions
|
@ -18,7 +18,7 @@ void setCurActivity(const ActivityId activityId)
|
|||
curActivity = activityId;
|
||||
}
|
||||
|
||||
Logger * logger = makeDefaultLogger();
|
||||
Logger * logger = makeSimpleLogger();
|
||||
|
||||
void Logger::warn(const std::string & msg)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ void writeToStderr(const string & s)
|
|||
}
|
||||
}
|
||||
|
||||
Logger * makeDefaultLogger()
|
||||
Logger * makeSimpleLogger()
|
||||
{
|
||||
return new SimpleLogger();
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
|
||||
virtual ~Logger() { }
|
||||
|
||||
virtual void stop() { };
|
||||
|
||||
virtual void log(Verbosity lvl, const FormatOrString & fs) = 0;
|
||||
|
||||
void log(const FormatOrString & fs)
|
||||
|
@ -141,7 +143,7 @@ struct PushActivity
|
|||
|
||||
extern Logger * logger;
|
||||
|
||||
Logger * makeDefaultLogger();
|
||||
Logger * makeSimpleLogger();
|
||||
|
||||
Logger * makeJSONLogger(Logger & prevLogger);
|
||||
|
||||
|
|
|
@ -989,7 +989,7 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
|
|||
{
|
||||
auto wrapper = [&]() {
|
||||
if (!options.allowVfork)
|
||||
logger = makeDefaultLogger();
|
||||
logger = makeSimpleLogger();
|
||||
try {
|
||||
#if __linux__
|
||||
if (options.dieWithParent && prctl(PR_SET_PDEATHSIG, SIGKILL) == -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue