Added a default log callback and attached the console at start.

This commit is contained in:
Arron David Nelson 2024-02-01 17:12:55 -08:00
parent 6fa7729253
commit beaa7cb034

View File

@ -1,6 +1,7 @@
#include "ehs/EHS.h" #include "ehs/EHS.h"
#include "ehs/Log.h" #include "ehs/Log.h"
#include "ehs/Version.h" #include "ehs/Version.h"
#include "ehs/io/Console.h"
#include "ehs/GarbageCollector.h" #include "ehs/GarbageCollector.h"
#include "ehs/io/audio/Audio.h" #include "ehs/io/audio/Audio.h"
#include "ehs/io/img/Img.h" #include "ehs/io/img/Img.h"
@ -620,8 +621,30 @@ namespace ehs
} }
} }
void LogRaised(const ehs::Log& log)
{
ehs::Array<ehs::Str_8> 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() int main()
{ {
ehs::Console::Attach();
ehs::Log::SetCallback(LogRaised);
ehs::Audio::AddCodec({ ehs::Audio::AddCodec({
"Waveform Audio", "Waveform Audio",
"wav", "wav",