Logging

Due to the lack of a true cross-platform logging mechanism in C++, cerlib provides its own.

Example:

cer::logInfo("Hello {}! Let's count: {}, {}, {}",
             "World", 1, 2, 3);

// Output: Hello World! Let's count: 1, 2, 3

cerlib’s logging mechanism respects the target platform, for example:

  • Logs to the Visual Studio output window in Visual Studio
  • Logs to Android Logcat on Android
  • Logs to stdout (i.e. terminal) on other platforms

Logging functions

cer::logInfo( format, args… )

  • Logs a normal message to the system output, indicating a status update.

cer::logWarning( format, args… )

  • Logs a warning to the system output, indicating that the developer should pay attention to some operation that was just performed.

cer::logError( format, args… )

  • Logs an error to the system output, indicating that the developer should fix a bug in the game.

cer::logDebug( format, args… )

  • Logs a normal message to the system output only in debug mode. In a release build, this is optimized away by the compiler and results in a no-op.

cer::logVerbose( format, args… )

  • Logs a normal message to the system output only in debug mode and only if the CERLIB_ENABLE_VERBOSE_LOGGING CMake option was enabled. In a release build, this is optimized away by the compiler and results in a no-op.