mirror of
https://github.com/NixOS/nix.git
synced 2025-12-19 15:31:07 +01:00
move showTrace to new loggerSettings
This commit is contained in:
parent
5ae498872a
commit
bf2788e4c1
10 changed files with 35 additions and 57 deletions
|
|
@ -22,11 +22,11 @@ LogFormat parseLogFormat(const std::string & logFormatStr) {
|
|||
Logger * makeDefaultLogger() {
|
||||
switch (defaultLogFormat) {
|
||||
case LogFormat::raw:
|
||||
return makeSimpleLogger(false, false);
|
||||
return makeSimpleLogger(false);
|
||||
case LogFormat::rawWithLogs:
|
||||
return makeSimpleLogger(true, false);
|
||||
return makeSimpleLogger(true);
|
||||
case LogFormat::internalJson:
|
||||
return makeJSONLogger(*makeSimpleLogger(true, false));
|
||||
return makeJSONLogger(*makeSimpleLogger(true));
|
||||
case LogFormat::bar:
|
||||
return makeProgressBar();
|
||||
case LogFormat::barWithLogs:
|
||||
|
|
|
|||
|
|
@ -81,14 +81,12 @@ private:
|
|||
|
||||
bool printBuildLogs;
|
||||
bool isTTY;
|
||||
bool showTrace;
|
||||
|
||||
public:
|
||||
|
||||
ProgressBar(bool printBuildLogs, bool isTTY)
|
||||
: printBuildLogs(printBuildLogs)
|
||||
, isTTY(isTTY)
|
||||
, showTrace(false)
|
||||
{
|
||||
state_.lock()->active = isTTY;
|
||||
updateThread = std::thread([&]() {
|
||||
|
|
@ -133,16 +131,10 @@ public:
|
|||
auto state(state_.lock());
|
||||
|
||||
std::stringstream oss;
|
||||
showErrorInfo(oss, ei, showTrace);
|
||||
showErrorInfo(oss, ei, loggerSettings.showTrace.get());
|
||||
|
||||
log(*state, ei.level, oss.str());
|
||||
}
|
||||
bool getShowTrace() const override {
|
||||
return showTrace;
|
||||
}
|
||||
void setShowTrace(bool showTrace) override {
|
||||
this->showTrace = showTrace;
|
||||
}
|
||||
|
||||
void log(State & state, Verbosity lvl, const std::string & s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -323,9 +323,8 @@ int handleExceptions(const string & programName, std::function<void()> fun)
|
|||
printError("Try '%1% --help' for more information.", programName);
|
||||
return 1;
|
||||
} catch (BaseError & e) {
|
||||
logger->setShowTrace(settings.showTrace);
|
||||
logError(e.info());
|
||||
if (e.hasTrace() && !settings.showTrace)
|
||||
if (e.hasTrace() && !loggerSettings.showTrace.get())
|
||||
printError("(use '--show-trace' to show detailed location information)");
|
||||
return e.status;
|
||||
} catch (std::bad_alloc & e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue