aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util/color.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/util/color.cpp')
-rw-r--r--src/crepe/util/color.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/crepe/util/color.cpp b/src/crepe/util/color.cpp
index 3fec157..bdf5809 100644
--- a/src/crepe/util/color.cpp
+++ b/src/crepe/util/color.cpp
@@ -1,4 +1,7 @@
+#include <cstdarg>
+
#include "color.h"
+#include "fmt.h"
#include "../api/Config.h"
using namespace crepe::util;
@@ -16,10 +19,18 @@ const string LogColor::str(const string & content) {
}
const char * LogColor::c_str(const char * content) {
- this->final = this->str(content);
+ this->final = this->str(content == NULL ? "" : content);
return this->final.c_str();
}
+const char * LogColor::fmt(const char * fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ string content = va_stringf(args, fmt);
+ va_end(args);
+ return this->c_str(content.c_str());
+}
+
LogColor & LogColor::add_code(unsigned int code) {
this->code += stringf("\e[%dm", code);
return *this;