Skip to content

Commit

Permalink
[Utils/Logger] Added Tracy messages to logging functions
Browse files Browse the repository at this point in the history
- The error one recovers part of the callstack to get a precise view of what could have failed
  • Loading branch information
Razakhel committed Mar 22, 2024
1 parent 3bc1b22 commit 1d128a8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/RaZ/Utils/Logger.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "RaZ/Utils/Logger.hpp"

#include "tracy/Tracy.hpp"

#include <iostream>

namespace Raz {
Expand All @@ -8,6 +10,8 @@ void Logger::error(const std::string& message) {
if (static_cast<int>(m_logLevel) < static_cast<int>(LoggingLevel::ERROR))
return;

TracyMessageCS(message.c_str(), message.size(), tracy::Color::Red, 10);

if (m_logFunc)
m_logFunc(LoggingLevel::ERROR, message);
else
Expand All @@ -18,6 +22,8 @@ void Logger::warn(const std::string& message) {
if (static_cast<int>(m_logLevel) < static_cast<int>(LoggingLevel::WARNING))
return;

TracyMessageC(message.c_str(), message.size(), tracy::Color::Gold);

if (m_logFunc)
m_logFunc(LoggingLevel::WARNING, message);
else
Expand All @@ -28,6 +34,8 @@ void Logger::info(const std::string& message) {
if (static_cast<int>(m_logLevel) < static_cast<int>(LoggingLevel::INFO))
return;

TracyMessageC(message.c_str(), message.size(), tracy::Color::DeepSkyBlue);

if (m_logFunc)
m_logFunc(LoggingLevel::INFO, message);
else
Expand All @@ -39,6 +47,8 @@ void Logger::debug(const std::string& message) {
if (static_cast<int>(m_logLevel) < static_cast<int>(LoggingLevel::DEBUG))
return;

TracyMessageC(message.c_str(), message.size(), tracy::Color::Gray);

if (m_logFunc)
m_logFunc(LoggingLevel::DEBUG, message);
else
Expand Down

0 comments on commit 1d128a8

Please sign in to comment.