From e58c98e224afcf4a28078344e0cd5f8c0e10961f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 21 Oct 2024 11:17:23 +0200 Subject: add logging example + finish log color config integration --- src/example/CMakeLists.txt | 1 + src/example/log.cpp | 25 +++++++++++++++++++++++++ src/example/script.cpp | 2 -- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/example/log.cpp (limited to 'src/example') diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 6df4ce7..4ef1cd1 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -15,4 +15,5 @@ endfunction() add_example(audio_internal) add_example(components_internal) add_example(script) +add_example(log) diff --git a/src/example/log.cpp b/src/example/log.cpp new file mode 100644 index 0000000..2d693d1 --- /dev/null +++ b/src/example/log.cpp @@ -0,0 +1,25 @@ +/** \file + * + * Standalone example for usage of the logging functions + */ + +#include +#include + +using namespace crepe; +using namespace crepe::util; + +int main() { + auto & cfg = api::Config::get_instance(); + // make sure all log messages get printed + cfg.log.level = util::log_level::TRACE; + + dbg_trace(); + dbg_logf("cfg.log.color is equal to %d", cfg.log.color); + logf(log_level::INFO, "info message!"); + logf(log_level::WARNING, "very scary warning"); + logf(log_level::ERROR, "fatal error!!!"); + + return 0; +} + diff --git a/src/example/script.cpp b/src/example/script.cpp index 91e4713..97e99b3 100644 --- a/src/example/script.cpp +++ b/src/example/script.cpp @@ -24,8 +24,6 @@ int main() { auto & cfg = api::Config::get_instance(); cfg.log.level = util::log_level::TRACE; - dbg_trace(); - auto obj = GameObject(0, "name", "tag", 0); obj.add_component().set_script(); -- cgit v1.2.3