aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-05 16:34:00 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-05 16:34:00 +0100
commit3d27e696185d6f4dfc9e978517ed17844044c5bc (patch)
treeaf65fdcdb44a1f9e6a84a294f267e6f743fea599 /src/crepe/util
parent6071387c2bbe6d36a95c113ad137e8e2ce80be27 (diff)
parentae6a103946e437ca85cc69c5fc2cbf68d35ffeae (diff)
Merge remote-tracking branch 'origin/max/gameobject' into max/scenes
Diffstat (limited to 'src/crepe/util')
-rw-r--r--src/crepe/util/CMakeLists.txt4
-rw-r--r--src/crepe/util/LogColor.cpp (renamed from src/crepe/util/color.cpp)7
-rw-r--r--src/crepe/util/LogColor.h (renamed from src/crepe/util/color.h)4
-rw-r--r--src/crepe/util/fmt.cpp4
-rw-r--r--src/crepe/util/fmt.h4
-rw-r--r--src/crepe/util/log.cpp10
-rw-r--r--src/crepe/util/log.h17
7 files changed, 25 insertions, 25 deletions
diff --git a/src/crepe/util/CMakeLists.txt b/src/crepe/util/CMakeLists.txt
index bbeaad9..3675bee 100644
--- a/src/crepe/util/CMakeLists.txt
+++ b/src/crepe/util/CMakeLists.txt
@@ -1,11 +1,11 @@
target_sources(crepe PUBLIC
- color.cpp
+ LogColor.cpp
log.cpp
fmt.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
- color.h
+ LogColor.h
log.h
fmt.h
)
diff --git a/src/crepe/util/color.cpp b/src/crepe/util/LogColor.cpp
index a7bbc81..b5fe3ea 100644
--- a/src/crepe/util/color.cpp
+++ b/src/crepe/util/LogColor.cpp
@@ -1,16 +1,17 @@
#include <cstdarg>
#include "../api/Config.h"
-#include "color.h"
+#include "LogColor.h"
+
#include "fmt.h"
-using namespace crepe::util;
+using namespace crepe;
using namespace std;
static constexpr const char * RESET_CODE = "\e[0m";
const string LogColor::str(const string & content) {
- auto & cfg = api::Config::get_instance();
+ auto & cfg = Config::get_instance();
string out = content;
if (cfg.log.color) out = this->code + out;
if (content.size() == 0) return out;
diff --git a/src/crepe/util/color.h b/src/crepe/util/LogColor.h
index 91e1abe..c1170cb 100644
--- a/src/crepe/util/color.h
+++ b/src/crepe/util/LogColor.h
@@ -2,7 +2,7 @@
#include <string>
-namespace crepe::util {
+namespace crepe {
class LogColor {
public:
@@ -48,4 +48,4 @@ private:
std::string final = "";
};
-} // namespace crepe::util
+} // namespace crepe
diff --git a/src/crepe/util/fmt.cpp b/src/crepe/util/fmt.cpp
index 397bf9f..4b50da8 100644
--- a/src/crepe/util/fmt.cpp
+++ b/src/crepe/util/fmt.cpp
@@ -6,7 +6,7 @@
using namespace std;
-string crepe::util::va_stringf(va_list args, const char * fmt) {
+string crepe::va_stringf(va_list args, const char * fmt) {
string out;
va_list args_copy;
@@ -26,7 +26,7 @@ string crepe::util::va_stringf(va_list args, const char * fmt) {
return out;
}
-string crepe::util::stringf(const char * fmt, ...) {
+string crepe::stringf(const char * fmt, ...) {
va_list args;
va_start(args, fmt);
string out = va_stringf(args, fmt);
diff --git a/src/crepe/util/fmt.h b/src/crepe/util/fmt.h
index 44c426f..e319e6e 100644
--- a/src/crepe/util/fmt.h
+++ b/src/crepe/util/fmt.h
@@ -2,9 +2,9 @@
#include <string>
-namespace crepe::util {
+namespace crepe {
std::string va_stringf(va_list args, const char * fmt);
std::string stringf(const char * fmt, ...);
-} // namespace crepe::util
+} // namespace crepe
diff --git a/src/crepe/util/log.cpp b/src/crepe/util/log.cpp
index 6bcc4ae..4a8f8e8 100644
--- a/src/crepe/util/log.cpp
+++ b/src/crepe/util/log.cpp
@@ -7,7 +7,7 @@
#include "fmt.h"
#include "log.h"
-using namespace crepe::util;
+using namespace crepe;
using namespace std;
string log_prefix(LogLevel level) {
@@ -27,25 +27,25 @@ string log_prefix(LogLevel level) {
}
static void log(LogLevel level, const string msg) {
- auto & cfg = crepe::api::Config::get_instance();
+ auto & cfg = Config::get_instance();
if (level < cfg.log.level) return;
string out = log_prefix(level) + msg;
if (!out.ends_with("\n")) out += "\n";
// TODO: also log to file or smth
- printf("%s", out.c_str());
+ fwrite(out.c_str(), 1, out.size(), stdout);
fflush(stdout);
}
-void crepe::util::logf(const char * fmt, ...) {
+void crepe::logf(const char * fmt, ...) {
va_list args;
va_start(args, fmt);
log(LogLevel::DEBUG, va_stringf(args, fmt));
va_end(args);
}
-void crepe::util::logf(LogLevel level, const char * fmt, ...) {
+void crepe::logf(LogLevel level, const char * fmt, ...) {
va_list args;
va_start(args, fmt);
log(level, va_stringf(args, fmt));
diff --git a/src/crepe/util/log.h b/src/crepe/util/log.h
index 308ba96..5a1cf00 100644
--- a/src/crepe/util/log.h
+++ b/src/crepe/util/log.h
@@ -3,28 +3,27 @@
// allow user to disable debug macros
#ifndef CREPE_DISABLE_MACROS
-#include "color.h"
+#include "LogColor.h"
// utility macros
#define _crepe_logf_here(level, format, ...) \
- crepe::util::logf( \
+ crepe::logf( \
level, "%s" format, \
- crepe::util::LogColor().fg_white(false).fmt( \
+ crepe::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_trace() _crepe_logf_here(crepe::util::LogLevel::TRACE, "%s", "")
+ _crepe_logf_here(crepe::LogLevel::DEBUG, ": " fmt, __VA_ARGS__)
+#define dbg_log(str) _crepe_logf_here(crepe::LogLevel::DEBUG, "%s: " str, "")
+#define dbg_trace() _crepe_logf_here(crepe::LogLevel::TRACE, "%s", "")
// NOLINTEND
#endif
-namespace crepe::util {
+namespace crepe {
enum LogLevel {
TRACE,
@@ -37,4 +36,4 @@ enum LogLevel {
void logf(const char * fmt, ...);
void logf(enum LogLevel level, const char * fmt, ...);
-} // namespace crepe::util
+} // namespace crepe