diff --git a/lib/mammoth/CMakeLists.txt b/lib/mammoth/CMakeLists.txt index 1c0f027..e177ddd 100644 --- a/lib/mammoth/CMakeLists.txt +++ b/lib/mammoth/CMakeLists.txt @@ -10,6 +10,7 @@ target_include_directories(mammoth_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(mammoth_lib + c zion_lib) set_target_properties(mammoth_lib PROPERTIES diff --git a/lib/mammoth/include/mammoth/debug.h b/lib/mammoth/include/mammoth/debug.h index 118d0fa..800a05a 100644 --- a/lib/mammoth/include/mammoth/debug.h +++ b/lib/mammoth/include/mammoth/debug.h @@ -3,7 +3,7 @@ #include #include -void dbgln(const char*); +void dbgln(const char* fmt, ...); // Checks that the code is ok. // if not exits the process. diff --git a/lib/mammoth/src/debug.cpp b/lib/mammoth/src/debug.cpp index 665e08c..cbe8632 100644 --- a/lib/mammoth/src/debug.cpp +++ b/lib/mammoth/src/debug.cpp @@ -1,13 +1,29 @@ #include "include/mammoth/debug.h" +#include +#include #include #include -void dbgln(const char* str) { - // Safe to ignore the result since right now this doesn't throw. +void dbgln_internal(const char* str) { // Safe to ignore the result since right + // now this doesn't throw. uint64_t _ = ZDebug(str); } +void dbgln(const char* fmt, ...) { + char str[1024]; + va_list arg; + va_start(arg, fmt); + int ret = vsprintf(str, fmt, arg); + va_end(arg); + + if (ret == -1 || ret > 1024) { + crash("Bad vsprintf", 1); + } + + dbgln_internal(str); +} + void check(uint64_t code) { switch (code) { case Z_OK: