Use Logger::stdout()

(cherry picked from commit 8f41847394)
This commit is contained in:
Eelco Dolstra 2020-04-16 13:46:37 +02:00
parent 67a5941472
commit efaffaa9d1
6 changed files with 11 additions and 15 deletions

View File

@ -50,7 +50,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
if (!dryRun)
store->addToStore(info, sink.s);
std::cout << fmt("%s\n", store->printStorePath(info.path));
logger->stdout("%s", store->printStorePath(info.path));
}
};

View File

@ -55,16 +55,15 @@ struct CmdEval : MixJSON, InstallableCommand
auto v = installable->toValue(*state).first;
PathSet context;
stopProgressBar();
if (raw) {
stopProgressBar();
std::cout << state->coerceToString(noPos, *v, context);
} else if (json) {
JSONPlaceholder jsonOut(std::cout);
printValueAsJSON(*state, true, *v, jsonOut, context);
} else {
state->forceValueDeep(*v);
std::cout << *v << "\n";
logger->stdout("%s", *v);
}
}
};

View File

@ -60,8 +60,7 @@ struct CmdHash : Command
Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
std::cout << format("%1%\n") %
h.to_string(base, base == SRI);
logger->stdout(h.to_string(base, base == SRI));
}
}
};
@ -95,7 +94,7 @@ struct CmdToBase : Command
void run() override
{
for (auto s : args)
std::cout << fmt("%s\n", Hash(s, ht).to_string(base, base == SRI));
logger->stdout(Hash(s, ht).to_string(base, base == SRI));
}
};

View File

@ -34,16 +34,14 @@ struct MixLs : virtual Args, MixJSON
(st.isExecutable ? "-r-xr-xr-x" : "-r--r--r--") :
st.type == FSAccessor::Type::tSymlink ? "lrwxrwxrwx" :
"dr-xr-xr-x";
std::cout <<
(format("%s %20d %s") % tp % st.fileSize % relPath);
auto line = fmt("%s %20d %s", tp, st.fileSize, relPath);
if (st.type == FSAccessor::Type::tSymlink)
std::cout << " -> " << accessor->readLink(curPath)
;
std::cout << "\n";
line += " -> " + accessor->readLink(curPath);
logger->stdout(line);
if (recursive && st.type == FSAccessor::Type::tDirectory)
doPath(st, curPath, relPath, false);
} else {
std::cout << relPath << "\n";
logger->stdout(relPath);
if (recursive) {
auto st = accessor->stat(curPath);
if (st.type == FSAccessor::Type::tDirectory)

View File

@ -23,7 +23,7 @@ struct CmdShowConfig : Command, MixJSON
std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings);
for (auto & s : settings)
std::cout << s.first + " = " + s.second.value + "\n";
logger->stdout("%s = %s", s.first, s.second.value);
}
}
};

View File

@ -149,7 +149,7 @@ struct CmdWhyDepends : SourceExprCommand
auto pathS = store->printStorePath(node.path);
assert(node.dist != inf);
std::cout << fmt("%s%s%s%s" ANSI_NORMAL "\n",
logger->stdout("%s%s%s%s" ANSI_NORMAL,
firstPad,
node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "" : "",