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