diff --git a/CMakeLists.txt b/CMakeLists.txt index 434733e..07c110e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 5.1.5) +set(BLT_VERSION 5.1.6) set(BLT_TARGET BLT) diff --git a/include/blt/logging/logging.h b/include/blt/logging/logging.h index c419895..82649f9 100644 --- a/include/blt/logging/logging.h +++ b/include/blt/logging/logging.h @@ -88,14 +88,19 @@ namespace blt::logging { if constexpr (std::is_trivially_copyable_v) { + // copy bytes of type char buffer[sizeof(T)]; std::memcpy(buffer, &t, sizeof(T)); + // display prefix if (type.alternate_form) stream << '0' << (type.uppercase ? 'B' : 'b'); + // print bytes for (size_t i = 0; i < sizeof(T); ++i) { + // print bits for (size_t j = 0; j < 8; ++j) stream << ((buffer[i] & (1 << j)) ? '1' : '0'); + // special seperator defined via sign (weird hack, change?) if (type.sign == fmt_sign_t::SPACE && i != sizeof(T) - 1) stream << ' '; } diff --git a/src/blt/logging/fmt_tokenizer.cpp b/src/blt/logging/fmt_tokenizer.cpp index 3bdf7e4..abdfcd4 100644 --- a/src/blt/logging/fmt_tokenizer.cpp +++ b/src/blt/logging/fmt_tokenizer.cpp @@ -154,6 +154,7 @@ namespace blt::logging switch (type) { case fmt_token_type::STRING: + return; case fmt_token_type::COLON: { std::stringstream ss; diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index d7729e7..ca342d6 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -20,9 +20,6 @@ int main() { - - using endl_t = decltype(static_cast(std::endl)); - // blt::logging::println("{} | {} | {} | {}", blt::type_string()); blt::logging::println("This is a println!"); blt::logging::println("This is a println with args '{}'", 42); blt::logging::println("This is a println with multiple args '{}' '{:.100}' '{}'", 42, 32.34231233f, "Hello World!"); @@ -40,5 +37,7 @@ int main() blt::logging::println("This is a println with hex with leading {:#.10x}", 4250); blt::logging::println("This is a println with binary {:#b}", 6969420); blt::logging::println("This is a println with binary with space {: #b}", 6969421); + blt::logging::println("This is a println with octal {:#o}", 6669); + blt::logging::println("This is a println with hexfloat {:a}", 402.4320); // blt::logging::println("This is println {}\twith a std::endl in the middle of it"); }