From beaa7cb034eb8251ea7307c55c5552b487b03a1e Mon Sep 17 00:00:00 2001 From: karutoh Date: Thu, 1 Feb 2024 17:12:55 -0800 Subject: [PATCH] Added a default log callback and attached the console at start. --- src/EHS.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/EHS.cpp b/src/EHS.cpp index e2a49a7..a12d78b 100644 --- a/src/EHS.cpp +++ b/src/EHS.cpp @@ -1,6 +1,7 @@ #include "ehs/EHS.h" #include "ehs/Log.h" #include "ehs/Version.h" +#include "ehs/io/Console.h" #include "ehs/GarbageCollector.h" #include "ehs/io/audio/Audio.h" #include "ehs/io/img/Img.h" @@ -620,8 +621,30 @@ namespace ehs } } +void LogRaised(const ehs::Log& log) +{ + ehs::Array tags = log.GetTags(); + + ehs::Str_8 result = "{"; + + for (ehs::UInt_32 i = 0; i < tags.Size(); ++i) + { + result += tags[i]; + if (i != tags.Size() - 1) + result += ", "; + } + + result += "} (" + ehs::Str_8::FromNum(log.GetCode()) + "): " + log.GetMsg(); + + ehs::Console::Write_8(result); +} + int main() { + ehs::Console::Attach(); + + ehs::Log::SetCallback(LogRaised); + ehs::Audio::AddCodec({ "Waveform Audio", "wav",