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) if (!dryRun)
store->addToStore(info, sink.s); 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; auto v = installable->toValue(*state).first;
PathSet context; PathSet context;
stopProgressBar();
if (raw) { if (raw) {
stopProgressBar();
std::cout << state->coerceToString(noPos, *v, context); std::cout << state->coerceToString(noPos, *v, context);
} else if (json) { } else if (json) {
JSONPlaceholder jsonOut(std::cout); JSONPlaceholder jsonOut(std::cout);
printValueAsJSON(*state, true, *v, jsonOut, context); printValueAsJSON(*state, true, *v, jsonOut, context);
} else { } else {
state->forceValueDeep(*v); 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; Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20); if (truncate && h.hashSize > 20) h = compressHash(h, 20);
std::cout << format("%1%\n") % logger->stdout(h.to_string(base, base == SRI));
h.to_string(base, base == SRI);
} }
} }
}; };
@ -95,7 +94,7 @@ struct CmdToBase : Command
void run() override void run() override
{ {
for (auto s : args) 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.isExecutable ? "-r-xr-xr-x" : "-r--r--r--") :
st.type == FSAccessor::Type::tSymlink ? "lrwxrwxrwx" : st.type == FSAccessor::Type::tSymlink ? "lrwxrwxrwx" :
"dr-xr-xr-x"; "dr-xr-xr-x";
std::cout << auto line = fmt("%s %20d %s", tp, st.fileSize, relPath);
(format("%s %20d %s") % tp % st.fileSize % relPath);
if (st.type == FSAccessor::Type::tSymlink) if (st.type == FSAccessor::Type::tSymlink)
std::cout << " -> " << accessor->readLink(curPath) line += " -> " + accessor->readLink(curPath);
; logger->stdout(line);
std::cout << "\n";
if (recursive && st.type == FSAccessor::Type::tDirectory) if (recursive && st.type == FSAccessor::Type::tDirectory)
doPath(st, curPath, relPath, false); doPath(st, curPath, relPath, false);
} else { } else {
std::cout << relPath << "\n"; logger->stdout(relPath);
if (recursive) { if (recursive) {
auto st = accessor->stat(curPath); auto st = accessor->stat(curPath);
if (st.type == FSAccessor::Type::tDirectory) if (st.type == FSAccessor::Type::tDirectory)

View file

@ -23,7 +23,7 @@ struct CmdShowConfig : Command, MixJSON
std::map<std::string, Config::SettingInfo> settings; std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings); globalConfig.getSettings(settings);
for (auto & s : 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); auto pathS = store->printStorePath(node.path);
assert(node.dist != inf); assert(node.dist != inf);
std::cout << fmt("%s%s%s%s" ANSI_NORMAL "\n", logger->stdout("%s%s%s%s" ANSI_NORMAL,
firstPad, firstPad,
node.visited ? "\e[38;5;244m" : "", node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "" : "", firstPad != "" ? "" : "",