aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-04-29 10:14:32 -0600
committerBen Burdette <bburdette@gmail.com>2020-04-29 10:14:32 -0600
commite2f61263ebf41958f4f3d6f6135377024e33457c (patch)
tree98bc0575a452f3282fcf385a32a2d24363389d6d /src/libutil
parent22e6490311015e076a09d5608834bd0dec1d7020 (diff)
uncrustify formatting
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/error.cc48
-rw-r--r--src/libutil/logging.cc42
-rw-r--r--src/libutil/logging.hh4
3 files changed, 46 insertions, 48 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 8f0e0aa1a..91fa1ccd8 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -45,17 +45,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
// previous line of code.
if (nixCode.prevLineOfCode.has_value()) {
std::cout << fmt("%1% %|2$5d|| %3%",
- prefix,
- (nixCode.errPos.line - 1),
- *nixCode.prevLineOfCode)
+ prefix,
+ (nixCode.errPos.line - 1),
+ *nixCode.prevLineOfCode)
<< std::endl;
}
// line of code containing the error.%2$+5d%
std::cout << fmt("%1% %|2$5d|| %3%",
- prefix,
- (nixCode.errPos.line),
- nixCode.errLineOfCode)
+ prefix,
+ (nixCode.errPos.line),
+ nixCode.errLineOfCode)
<< std::endl;
// error arrows for the column range.
@@ -69,17 +69,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
std::string arrows("^");
std::cout << fmt("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL,
- prefix,
- spaces,
- arrows) << std::endl;
+ prefix,
+ spaces,
+ arrows) << std::endl;
}
// next line of code.
if (nixCode.nextLineOfCode.has_value()) {
std::cout << fmt("%1% %|2$5d|| %3%",
- prefix,
- (nixCode.errPos.line + 1),
- *nixCode.nextLineOfCode)
+ prefix,
+ (nixCode.errPos.line + 1),
+ *nixCode.nextLineOfCode)
<< std::endl;
}
}
@@ -149,18 +149,18 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
// divider.
if (einfo.name != "")
out << fmt("%1%%2%" ANSI_BLUE " --- %3% %4% %5%" ANSI_NORMAL,
- prefix,
- levelString,
- einfo.name,
- dashes,
- einfo.programName.value_or(""))
+ prefix,
+ levelString,
+ einfo.name,
+ dashes,
+ einfo.programName.value_or(""))
<< std::endl;
else
out << fmt("%1%%2%" ANSI_BLUE " -----%3% %4%" ANSI_NORMAL,
- prefix,
- levelString,
- dashes,
- einfo.programName.value_or(""))
+ prefix,
+ levelString,
+ dashes,
+ einfo.programName.value_or(""))
<< std::endl;
// filename.
@@ -171,9 +171,9 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
: "";
out << fmt("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL,
- prefix,
- einfo.nixCode->errPos.file,
- eline) << std::endl;
+ prefix,
+ einfo.nixCode->errPos.file,
+ eline) << std::endl;
out << prefix << std::endl;
} else {
out << fmt("%1%from command line argument", prefix) << std::endl;
diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc
index 4a8b98640..e1750eb2a 100644
--- a/src/libutil/logging.cc
+++ b/src/libutil/logging.cc
@@ -60,7 +60,7 @@ public:
void logEI(const ErrorInfo & ei) override
{
- std::stringstream oss;
+ std::stringstream oss;
oss << ei;
log(ei.level, oss.str());
@@ -68,7 +68,7 @@ public:
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
const std::string & s, const Fields & fields, ActivityId parent)
- override
+ override
{
if (lvl <= verbosity && !s.empty())
log(lvl, s + "...");
@@ -111,8 +111,7 @@ Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type,
logger.startActivity(id, lvl, type, s, fields, parent);
}
-struct JSONLogger : Logger
-{
+struct JSONLogger : Logger {
Logger & prevLogger;
JSONLogger(Logger & prevLogger) : prevLogger(prevLogger) { }
@@ -155,28 +154,26 @@ struct JSONLogger : Logger
json["level"] = ei.level;
json["msg"] = oss.str();
- // Extra things that COULD go into json. Useful?
+ // Extra things that COULD go into json. Useful?
// TODO: decide if useful.
// TODO: make a json obj that goes into json["msg"]?
json["name"] = ei.name;
json["description"] = ei.description;
- if (ei.hint.has_value())
- {
- json["hint"] = ei.hint->str();
+ if (ei.hint.has_value()) {
+ json["hint"] = ei.hint->str();
}
- if (ei.nixCode.has_value())
- {
- if (ei.nixCode->errPos.line != 0)
- json["line"] = ei.nixCode->errPos.line;
- if (ei.nixCode->errPos.column != 0)
- json["column"] = ei.nixCode->errPos.column;
- if (ei.nixCode->errPos.file != "")
- json["file"] = ei.nixCode->errPos.file;
- if (ei.nixCode->prevLineOfCode.has_value())
- json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
- json["errLineOfCode"] = ei.nixCode->errLineOfCode;
- if (ei.nixCode->nextLineOfCode.has_value())
- json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
+ if (ei.nixCode.has_value()) {
+ if (ei.nixCode->errPos.line != 0)
+ json["line"] = ei.nixCode->errPos.line;
+ if (ei.nixCode->errPos.column != 0)
+ json["column"] = ei.nixCode->errPos.column;
+ if (ei.nixCode->errPos.file != "")
+ json["file"] = ei.nixCode->errPos.file;
+ if (ei.nixCode->prevLineOfCode.has_value())
+ json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
+ json["errLineOfCode"] = ei.nixCode->errLineOfCode;
+ if (ei.nixCode->nextLineOfCode.has_value())
+ json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
}
write(json);
@@ -278,7 +275,8 @@ bool handleJSONLogMessage(const std::string & msg,
return true;
}
-Activity::~Activity() {
+Activity::~Activity()
+{
try {
logger.stopActivity(id);
} catch (...) {
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 89fd98419..0c4980b83 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -62,12 +62,12 @@ public:
virtual void logEI(const ErrorInfo &ei) = 0;
- void logEI(Verbosity lvl, ErrorInfo ei)
+ void logEI(Verbosity lvl, ErrorInfo ei)
{
ei.level = lvl;
logEI(ei);
}
-
+
virtual void warn(const std::string & msg);
virtual void startActivity(ActivityId act, Verbosity lvl, ActivityType type,