Skip to content

Commit

Permalink
feat(logging): Add level for success messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Nov 12, 2024
1 parent 3fc8455 commit f0992cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
20 changes: 20 additions & 0 deletions include/SparkyStudios/Audio/Amplitude/Core/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@
*/
#define amLogCritical(_message_, ...) amLog(Critical, _message_, ##__VA_ARGS__)

/**
* @brief Logs a success message.
*
* @param _message_ The message to log.
* @param ... The arguments to format the message with.
*
* @ingroup core
*/
#define amLogSuccess(_message_,...) amLog(Success, _message_, ##__VA_ARGS__)

namespace SparkyStudios::Audio::Amplitude
{
/**
Expand All @@ -109,6 +119,7 @@ namespace SparkyStudios::Audio::Amplitude
eLogMessageLevel_Warning = 2, ///< Warning messages.
eLogMessageLevel_Error = 3, ///< Error messages.
eLogMessageLevel_Critical = 4, ///< Critical messages.
eLogMessageLevel_Success = 5, ///< Success messages.
};

/**
Expand Down Expand Up @@ -186,6 +197,15 @@ namespace SparkyStudios::Audio::Amplitude
*/
void Critical(const char* file, int line, const AmString& message);

/**
* @brief Logs a success message.
*
* @param[in] file The file where the message was logged.
* @param[in] line The line where the message was logged.
* @param[in] message The message to log.
*/
void Success(const char* file, int line, const AmString& message);

protected:
/**
* @brief Logs a message with the given level.
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Drivers/MiniAudio/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace SparkyStudios::Audio::Amplitude
{
AM_UNUSED(pInput);

auto* driver = static_cast<MiniAudioDriver*>(pDevice->pUserData);
const auto* driver = static_cast<MiniAudioDriver*>(pDevice->pUserData);

AudioBuffer* pOutputBuffer = nullptr;
frameCount = amEngine->GetMixer()->Mix(&pOutputBuffer, frameCount);
Expand Down
8 changes: 8 additions & 0 deletions src/Core/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace SparkyStudios::Audio::Amplitude
Log(eLogMessageLevel_Critical, file, line, message);
}

void Logger::Success(const char* file, int line, const AmString& message)
{
Log(eLogMessageLevel_Success, file, line, message);
}

ConsoleLogger::ConsoleLogger(bool displayFileAndLine)
: m_displayFileAndLine(displayFileAndLine)
{}
Expand All @@ -80,6 +85,9 @@ namespace SparkyStudios::Audio::Amplitude
case eLogMessageLevel_Critical:
std::cout << "[CRITICAL] ";
break;
case eLogMessageLevel_Success:
std::cout << "[SUCCESS] ";
break;
}

if (m_displayFileAndLine)
Expand Down

0 comments on commit f0992cd

Please sign in to comment.