From 577f5b359d733e804b48454515c94598f32c909b Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 29 Dec 2022 06:32:45 +0100 Subject: [PATCH] Test: Logging - C++(11) --- test/test_log_cxx.cc | 95 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 10 deletions(-) diff --git a/test/test_log_cxx.cc b/test/test_log_cxx.cc index fa37b4b..b5b7f68 100644 --- a/test/test_log_cxx.cc +++ b/test/test_log_cxx.cc @@ -2,18 +2,93 @@ //#include #include #include -#include "../src/valog.h" +#include "../src/log.h" #include +#include + +// ORCA LOG C++ usage int main() { - // C++ usage - ORCA_LOG_ERR(); - ORCA_LOG_ERR("HELLO"); - std::string str{ "fds" }; - ORCA_LOG_ERR("string: %s", str.c_str()); - // { - // // C++ usage - // ORCA_LOG_ERR("%s",std::string("test: " + std::string(str) + "end").c_str()); - // } + // Test Levels + { + ORCA_LOG_ERR("SHOULD NOT SEE THIS"); + + Orca::Log::set_level(ORCA_LOG_LEVEL_ALL); + ORCA_LOG_ERR(""); + ORCA_LOG_WARN(""); + ORCA_LOG_INFO(""); + + Orca::Log::set_level(ORCA_LOG_LEVEL_ERROR); + ORCA_LOG_ERR(""); + ORCA_LOG_WARN("SHOULD NOT SEE THIS"); + ORCA_LOG_INFO("SHOULD NOT SEE THIS"); + } + + // BASIC USAGE MACRO + { + Orca::Log::set_level(ORCA_LOG_LEVEL_INFO); + // no message + ORCA_LOG_INFO(""); + + // literals + ORCA_LOG_INFO("literal"); + + // string concats + std::string str{ "casts" }; + ORCA_LOG_ERR("everything " + str + " to a string"); + + // operator<< overloads + int i{ 23 }; + ORCA_LOG_ERR(i); + } + + // BASIC USAGE FUNCTIONS + { + Orca::Log::set_level(ORCA_LOG_LEVEL_INFO); + // no message + Orca::Log::log(""); + + // literals + Orca::Log::log("literal"); + + // string concats + std::string str{ "casts" }; + Orca::Log::log("everything " + str + " to a string"); + + // operator<< overloads + // WONT compile, needs std::string + // int i{ 23 }; + // Orca::Log::log(i); + + Orca::Log::logH1("HEADING 1"); + Orca::Log::logH2("HEADING 2"); + Orca::Log::logH3("HEADING 3"); + } + + // Colors functions only + { + Orca::Log::logH1("Colors functions only"); + Orca::Log::log("BLUE LOG", ORCA_LOG_COLOR_BLUE); + Orca::Log::log("DEFAULT COLOR"); + Orca::Log::set_color(ORCA_LOG_COLOR_GREEN); + Orca::Log::log("DEFAULT COLOR AFTER SET GREEN"); + Orca::Log::log("YELLOW ONE OFF", ORCA_LOG_COLOR_YELLOW); + Orca::Log::log("DEFAULT COLOR AGAIN"); + } + + // Colors using Macros + { + Orca::Log::set_color(ORCA_LOG_COLOR_DEFAULT); + Orca::Log::logH1("Colors using Macros"); + ORCA_LOG_ERR("DEFAULT COLOR"); + Orca::Log::log("BLUE LOG", ORCA_LOG_COLOR_BLUE); + ORCA_LOG_ERR("DEFAULT COLOR AGAIN"); + Orca::Log::set_color(ORCA_LOG_COLOR_GREEN); + Orca::Log::log("YELLOW ONE OFF", ORCA_LOG_COLOR_YELLOW); + ORCA_LOG_ERR("DEFAULT COLOR GREEN"); + } + + + // FUNCTIONS }