comments and cleanup
This commit is contained in:
parent
70bcb39d3f
commit
9159dfe3d8
|
@ -197,11 +197,11 @@ std::ostream & operator << (std::ostream & str, const Pos & pos)
|
|||
if (!pos)
|
||||
str << "undefined position";
|
||||
else
|
||||
{
|
||||
{
|
||||
auto f = format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%");
|
||||
switch (pos.origin) {
|
||||
switch (pos.origin) {
|
||||
case foFile:
|
||||
f % (string) pos.file;
|
||||
f % (string) pos.file;
|
||||
break;
|
||||
case foStdin:
|
||||
case foString:
|
||||
|
|
|
@ -134,7 +134,6 @@ public:
|
|||
|
||||
std::stringstream oss;
|
||||
showErrorInfo(oss, ei, showTrace);
|
||||
// oss << ei;
|
||||
|
||||
log(*state, ei.level, oss.str());
|
||||
}
|
||||
|
|
|
@ -325,7 +325,6 @@ int handleExceptions(const string & programName, std::function<void()> fun)
|
|||
} catch (BaseError & e) {
|
||||
logger->setShowTrace(settings.showTrace);
|
||||
logError(e.info());
|
||||
// TODO fix to detect non-empty trace here.
|
||||
if (e.hasTrace() && !settings.showTrace)
|
||||
printError("(use '--show-trace' to show detailed location information)");
|
||||
return e.status;
|
||||
|
|
|
@ -80,10 +80,9 @@ struct TunnelLogger : public Logger
|
|||
|
||||
std::stringstream oss;
|
||||
showErrorInfo(oss, ei, false);
|
||||
// oss << ei;
|
||||
|
||||
StringSink buf;
|
||||
buf << STDERR_NEXT << oss.str() << "\n"; // (fs.s + "\n");
|
||||
buf << STDERR_NEXT << oss.str() << "\n";
|
||||
enqueueMsg(*buf.s);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ const string& BaseError::calcWhat() const
|
|||
|
||||
std::ostringstream oss;
|
||||
showErrorInfo(oss, err, false);
|
||||
// oss << err;
|
||||
what_ = oss.str();
|
||||
|
||||
return *what_;
|
||||
|
@ -35,7 +34,6 @@ const string& BaseError::calcWhat() const
|
|||
}
|
||||
|
||||
std::optional<string> ErrorInfo::programName = std::nullopt;
|
||||
// bool ErrorInfo::showTrace = false;
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const hintformat &hf)
|
||||
{
|
||||
|
@ -212,7 +210,6 @@ void printAtPos(const string &prefix, const ErrPos &pos, std::ostream &out)
|
|||
}
|
||||
}
|
||||
|
||||
// std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||
std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool showTrace)
|
||||
{
|
||||
auto errwidth = std::max<size_t>(getWindowSize().second, 20);
|
||||
|
|
|
@ -111,10 +111,8 @@ struct ErrorInfo {
|
|||
std::list<Trace> traces;
|
||||
|
||||
static std::optional<string> programName;
|
||||
// static bool showTrace;
|
||||
};
|
||||
|
||||
// std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo);
|
||||
std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool showTrace);
|
||||
|
||||
/* BaseError should generally not be caught, as it has Interrupted as
|
||||
|
@ -122,7 +120,6 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show
|
|||
class BaseError : public std::exception
|
||||
{
|
||||
protected:
|
||||
// string prefix_; // used for location traces etc.
|
||||
mutable ErrorInfo err;
|
||||
|
||||
mutable std::optional<string> what_;
|
||||
|
|
|
@ -81,7 +81,6 @@ public:
|
|||
{
|
||||
std::stringstream oss;
|
||||
showErrorInfo(oss, ei, showTrace);
|
||||
// oss << ei;
|
||||
|
||||
log(ei.level, oss.str());
|
||||
}
|
||||
|
@ -158,7 +157,7 @@ struct JSONLogger : Logger {
|
|||
void setShowTrace(bool showTrace) override {
|
||||
prevLogger.setShowTrace(showTrace);
|
||||
}
|
||||
|
||||
|
||||
void addFields(nlohmann::json & json, const Fields & fields)
|
||||
{
|
||||
if (fields.empty()) return;
|
||||
|
@ -190,7 +189,6 @@ struct JSONLogger : Logger {
|
|||
{
|
||||
std::ostringstream oss;
|
||||
showErrorInfo(oss, ei, getShowTrace());
|
||||
// oss << ei;
|
||||
|
||||
nlohmann::json json;
|
||||
json["action"] = "msg";
|
||||
|
|
|
@ -149,8 +149,7 @@ struct PushActivity
|
|||
|
||||
extern Logger * logger;
|
||||
|
||||
Logger * makeSimpleLogger(bool printBuildLogs, bool showTrace);
|
||||
// Logger * makeSimpleLogger(bool printBuildLogs = true, bool showTrace);
|
||||
Logger * makeSimpleLogger(bool printBuildLogs = true, bool showTrace = false);
|
||||
|
||||
Logger * makeJSONLogger(Logger & prevLogger);
|
||||
|
||||
|
|
|
@ -972,7 +972,7 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
|
|||
{
|
||||
auto wrapper = [&]() {
|
||||
if (!options.allowVfork)
|
||||
logger = makeSimpleLogger(true, false); // TODO remove args.
|
||||
logger = makeSimpleLogger();
|
||||
try {
|
||||
#if __linux__
|
||||
if (options.dieWithParent && prctl(PR_SET_PDEATHSIG, SIGKILL) == -1)
|
||||
|
|
Loading…
Reference in a new issue