aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:56:19 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:56:19 +0200
commite7377daf2fe3b759fbbf7e57f88c412c3b1cf011 (patch)
treed4b3af9e752b0e42116b992d27654bac5c5710ad /src/crepe/util
parent58465175e761a908752542255fe584ce3aa1d163 (diff)
`make format`
Diffstat (limited to 'src/crepe/util')
-rw-r--r--src/crepe/util/color.cpp67
-rw-r--r--src/crepe/util/color.h2
-rw-r--r--src/crepe/util/log.cpp18
-rw-r--r--src/crepe/util/log.h13
4 files changed, 71 insertions, 29 deletions
diff --git a/src/crepe/util/color.cpp b/src/crepe/util/color.cpp
index bdf5809..a7bbc81 100644
--- a/src/crepe/util/color.cpp
+++ b/src/crepe/util/color.cpp
@@ -1,8 +1,8 @@
#include <cstdarg>
+#include "../api/Config.h"
#include "color.h"
#include "fmt.h"
-#include "../api/Config.h"
using namespace crepe::util;
using namespace std;
@@ -41,20 +41,51 @@ LogColor & LogColor::reset() {
return *this;
}
-LogColor & LogColor::fg_black(bool bright) { return this->add_code(bright ? 90 : 30); }
-LogColor & LogColor::fg_red(bool bright) { return this->add_code(bright ? 91 : 31); }
-LogColor & LogColor::fg_green(bool bright) { return this->add_code(bright ? 92 : 32); }
-LogColor & LogColor::fg_yellow(bool bright) { return this->add_code(bright ? 93 : 33); }
-LogColor & LogColor::fg_blue(bool bright) { return this->add_code(bright ? 94 : 34); }
-LogColor & LogColor::fg_magenta(bool bright) { return this->add_code(bright ? 95 : 35); }
-LogColor & LogColor::fg_cyan(bool bright) { return this->add_code(bright ? 96 : 36); }
-LogColor & LogColor::fg_white(bool bright) { return this->add_code(bright ? 97 : 37); }
-LogColor & LogColor::bg_black(bool bright) { return this->add_code(bright ? 100 : 40); }
-LogColor & LogColor::bg_red(bool bright) { return this->add_code(bright ? 101 : 41); }
-LogColor & LogColor::bg_green(bool bright) { return this->add_code(bright ? 102 : 42); }
-LogColor & LogColor::bg_yellow(bool bright) { return this->add_code(bright ? 103 : 43); }
-LogColor & LogColor::bg_blue(bool bright) { return this->add_code(bright ? 104 : 44); }
-LogColor & LogColor::bg_magenta(bool bright) { return this->add_code(bright ? 105 : 45); }
-LogColor & LogColor::bg_cyan(bool bright) { return this->add_code(bright ? 106 : 46); }
-LogColor & LogColor::bg_white(bool bright) { return this->add_code(bright ? 107 : 47); }
-
+LogColor & LogColor::fg_black(bool bright) {
+ return this->add_code(bright ? 90 : 30);
+}
+LogColor & LogColor::fg_red(bool bright) {
+ return this->add_code(bright ? 91 : 31);
+}
+LogColor & LogColor::fg_green(bool bright) {
+ return this->add_code(bright ? 92 : 32);
+}
+LogColor & LogColor::fg_yellow(bool bright) {
+ return this->add_code(bright ? 93 : 33);
+}
+LogColor & LogColor::fg_blue(bool bright) {
+ return this->add_code(bright ? 94 : 34);
+}
+LogColor & LogColor::fg_magenta(bool bright) {
+ return this->add_code(bright ? 95 : 35);
+}
+LogColor & LogColor::fg_cyan(bool bright) {
+ return this->add_code(bright ? 96 : 36);
+}
+LogColor & LogColor::fg_white(bool bright) {
+ return this->add_code(bright ? 97 : 37);
+}
+LogColor & LogColor::bg_black(bool bright) {
+ return this->add_code(bright ? 100 : 40);
+}
+LogColor & LogColor::bg_red(bool bright) {
+ return this->add_code(bright ? 101 : 41);
+}
+LogColor & LogColor::bg_green(bool bright) {
+ return this->add_code(bright ? 102 : 42);
+}
+LogColor & LogColor::bg_yellow(bool bright) {
+ return this->add_code(bright ? 103 : 43);
+}
+LogColor & LogColor::bg_blue(bool bright) {
+ return this->add_code(bright ? 104 : 44);
+}
+LogColor & LogColor::bg_magenta(bool bright) {
+ return this->add_code(bright ? 105 : 45);
+}
+LogColor & LogColor::bg_cyan(bool bright) {
+ return this->add_code(bright ? 106 : 46);
+}
+LogColor & LogColor::bg_white(bool bright) {
+ return this->add_code(bright ? 107 : 47);
+}
diff --git a/src/crepe/util/color.h b/src/crepe/util/color.h
index 66f3a28..91e1abe 100644
--- a/src/crepe/util/color.h
+++ b/src/crepe/util/color.h
@@ -48,4 +48,4 @@ private:
std::string final = "";
};
-} // namespace crepe::util::color
+} // namespace crepe::util
diff --git a/src/crepe/util/log.cpp b/src/crepe/util/log.cpp
index 5ff2ad4..6bcc4ae 100644
--- a/src/crepe/util/log.cpp
+++ b/src/crepe/util/log.cpp
@@ -3,20 +3,25 @@
#include <cstdlib>
#include <string>
+#include "../api/Config.h"
#include "fmt.h"
#include "log.h"
-#include "../api/Config.h"
using namespace crepe::util;
using namespace std;
string log_prefix(LogLevel level) {
switch (level) {
- case LogLevel::TRACE: return LogColor().fg_white().str("[TRACE]") + " ";
- case LogLevel::DEBUG: return LogColor().fg_magenta().str("[DEBUG]") + " ";
- case LogLevel::INFO: return LogColor().fg_blue().str("[INFO]") + " ";
- case LogLevel::WARNING: return LogColor().fg_yellow().str("[WARN]") + " ";
- case LogLevel::ERROR: return LogColor().fg_red().str("[ERROR]") + " ";
+ case LogLevel::TRACE:
+ return LogColor().fg_white().str("[TRACE]") + " ";
+ case LogLevel::DEBUG:
+ return LogColor().fg_magenta().str("[DEBUG]") + " ";
+ case LogLevel::INFO:
+ return LogColor().fg_blue().str("[INFO]") + " ";
+ case LogLevel::WARNING:
+ return LogColor().fg_yellow().str("[WARN]") + " ";
+ case LogLevel::ERROR:
+ return LogColor().fg_red().str("[ERROR]") + " ";
}
return "";
}
@@ -46,4 +51,3 @@ void crepe::util::logf(LogLevel level, const char * fmt, ...) {
log(level, va_stringf(args, fmt));
va_end(args);
}
-
diff --git a/src/crepe/util/log.h b/src/crepe/util/log.h
index 5ee67eb..308ba96 100644
--- a/src/crepe/util/log.h
+++ b/src/crepe/util/log.h
@@ -6,12 +6,19 @@
#include "color.h"
// utility macros
-#define _crepe_logf_here(level, format, ...) crepe::util::logf(level, "%s" format, crepe::util::LogColor().fg_white(false).fmt("%s (%s:%d)", __PRETTY_FUNCTION__, __FILE_NAME__, __LINE__), __VA_ARGS__)
+#define _crepe_logf_here(level, format, ...) \
+ crepe::util::logf( \
+ level, "%s" format, \
+ crepe::util::LogColor().fg_white(false).fmt( \
+ "%s (%s:%d)", __PRETTY_FUNCTION__, __FILE_NAME__, __LINE__), \
+ __VA_ARGS__)
// very illegal global function-style macros
// NOLINTBEGIN
-#define dbg_logf(fmt, ...) _crepe_logf_here(crepe::util::LogLevel::DEBUG, ": " fmt, __VA_ARGS__)
-#define dbg_log(str) _crepe_logf_here(crepe::util::LogLevel::DEBUG, "%s: " str, "")
+#define dbg_logf(fmt, ...) \
+ _crepe_logf_here(crepe::util::LogLevel::DEBUG, ": " fmt, __VA_ARGS__)
+#define dbg_log(str) \
+ _crepe_logf_here(crepe::util::LogLevel::DEBUG, "%s: " str, "")
#define dbg_trace() _crepe_logf_here(crepe::util::LogLevel::TRACE, "%s", "")
// NOLINTEND