Add buffer-based logging system

This commit is contained in:
Justin C. Miller
2019-03-17 14:28:31 -07:00
parent 94c491d286
commit c592f5f537
7 changed files with 1143 additions and 0 deletions

32
src/tests/logger.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include "kutil/constexpr_hash.h"
#include "kutil/logger.h"
#include "catch.hpp"
using namespace kutil;
uint8_t test_log_buffer[0x400];
const char *name1 = "test_area1";
log::area_t hash1 = "test_area1"_h;
const char *name2 = "test_area2";
log::area_t hash2 = "test_area2"_h;
TEST_CASE( "logger writing", "[logger]" )
{
log::logger logger(test_log_buffer, sizeof(test_log_buffer));
logger.register_area(hash1, name1, log::level::debug);
logger.register_area(hash2, name2, log::level::debug);
CHECK( hash1 != hash2 );
const char *check1 = logger.area_name(hash1);
const char *check2 = logger.area_name(hash2);
CHECK( check1 == name1 );
CHECK( check2 == name2 );
log::debug(hash1, "This is a thing %016lx", 35);
log::info(hash2, "This is a string %s", "foo");
log::warn(hash1, "This is a thing %016lx", 682);
log::error(hash2, "This is a string %s", "bar");
}