Skip to content

Commit af7416f

Browse files
committed
Add support for tracy logging output
Signed-off-by: Rye <[email protected]>
1 parent 18ee3f0 commit af7416f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

indra/llcommon/llerror.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,51 @@ namespace {
345345
}
346346
};
347347
#endif
348+
349+
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY
350+
class RecordToTracy : public LLError::Recorder
351+
{
352+
public:
353+
RecordToTracy()
354+
{
355+
this->showMultiline(true);
356+
this->showTags(false);
357+
this->showLocation(false);
358+
}
359+
360+
virtual bool enabled() override { return LLError::getEnabledLogTypesMask() & 0x12; }
361+
362+
virtual void recordMessage(LLError::ELevel level, const std::string& message) override
363+
{
364+
LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
365+
switch (level)
366+
{
367+
case LLError::LEVEL_DEBUG:
368+
{
369+
TracyMessageC(message.c_str(), message.size(), tracy::Color::Turquoise);
370+
break;
371+
}
372+
default:
373+
case LLError::LEVEL_NONE:
374+
case LLError::LEVEL_INFO:
375+
{
376+
TracyMessageC(message.c_str(), message.size(), tracy::Color::White);
377+
break;
378+
}
379+
case LLError::LEVEL_WARN:
380+
{
381+
TracyMessageC(message.c_str(), message.size(), tracy::Color::Yellow);
382+
break;
383+
}
384+
case LLError::LEVEL_ERROR:
385+
{
386+
TracyMessageC(message.c_str(), message.size(), tracy::Color::Red);
387+
break;
388+
}
389+
}
390+
}
391+
};
392+
#endif
348393
}
349394

350395

@@ -760,6 +805,11 @@ namespace
760805
LLError::addRecorder(recordToWinDebug);
761806
#endif
762807

808+
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY
809+
LLError::RecorderPtr recordToTracy(new RecordToTracy());
810+
LLError::addRecorder(recordToTracy);
811+
#endif
812+
763813
LogControlFile& e = LogControlFile::fromDirectory(user_dir, app_dir);
764814

765815
// NOTE: We want to explicitly load the file before we add it to the event timer

0 commit comments

Comments
 (0)