diff options
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/example/log.cpp | 25 | ||||
-rw-r--r-- | src/example/script.cpp | 4 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 587a7bd..fea6f60 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -19,6 +19,7 @@ endfunction() add_example(audio_internal) # add_example(components_internal) add_example(script) +add_example(log) add_example(rendering) add_example(asset_manager) add_example(particle) diff --git a/src/example/log.cpp b/src/example/log.cpp new file mode 100644 index 0000000..86ef193 --- /dev/null +++ b/src/example/log.cpp @@ -0,0 +1,25 @@ +/** \file + * + * Standalone example for usage of the logging functions + */ + +#include <crepe/util/log.h> +#include <crepe/api/Config.h> + +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::LogLevel::TRACE; + + dbg_trace(); + dbg_logf("cfg.log.color is equal to %d", cfg.log.color); + logf(LogLevel::INFO, "info message!"); + logf(LogLevel::WARNING, "very scary warning"); + logf(LogLevel::ERROR, "fatal error!!!"); + + return 0; +} + diff --git a/src/example/script.cpp b/src/example/script.cpp index 6e5563c..f737a90 100644 --- a/src/example/script.cpp +++ b/src/example/script.cpp @@ -7,6 +7,7 @@ #include <crepe/ScriptSystem.h> #include <crepe/util/log.h> +#include <crepe/api/Config.h> #include <crepe/api/BehaviorScript.h> #include <crepe/api/GameObject.h> #include <crepe/api/Script.h> @@ -20,7 +21,8 @@ class MyScript : public Script { }; int main() { - dbg_trace(); + auto & cfg = api::Config::get_instance(); + cfg.log.level = util::LogLevel::TRACE; auto obj = GameObject(0, "name", "tag", 0); obj.add_component<BehaviorScript>().set_script<MyScript>(); |