Cogs.Foundation
Loading...
Searching...
No Matches
Logging

The logging functionality found in Cogs::Logging can be used to gather output from your program and pipe it through a controlled interface.

To use logging the developer must:

  • Include the logging headers.
  • Create a logger instance
  • Use the appropriate methods, or preferably the logging macros provided.
#include <Foundation/Logging/Logger.h>
namespace
{
// Create a log instance to send our output to.
// Set up a callback function to handle log messages.
void printfCallback(const char * message, const char * source, int category)
{
printf("[%d][%s][%s]", category, source, message);
}
}
int main()
{
// Set the callback function so that log output will be sent here
Cogs::Logging::setLoggerCallback(printfCallback);
// Log a message with the debug category.
LOG_DEBUG(log, "Debug message.");
// Log a message with the info category, formatting text.
LOG_INFO(log, "Some numeric info: %d", 123);
...
}
#define LOG_INFO(logInstance,...)
Definition: Logger.h:18
#define LOG_DEBUG(logInstance,...)
Definition: Logger.h:14
Log implementation class.
Definition: LogManager.h:139
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:180