Console Logging and Logfiles¶
We use spdlog for console logging and logfiles.
Everything that is written to the console is automatically also written to
vulkan-renderer.log.The logfile
vulkan-renderer.logis completely overwritten upon every start ofinexor-vulkan-renderer-example.Unit tests and benchmarks (
inexor-vulkan-renderer-testsandinexor-vulkan-renderer-benchmarks) do not create any logfiles.We use the following format for log messages:
%Y-%m-%d %T.%f %^%l%$ %5t [%-10n] %v%Yis the year%mis the month (01 to 12)%dis the day of month (01 to 31)%Tis ISO 8601 time format (HH:MM:SS)%fis the microsecond part of the current second%^%l%$is the color-coded log level%5tis the thread id formatted to a string of length 5[%-10n]is the name of the logger, limited to 10 characters%vis the log message
For more information, check out spdlog’s documentation about custom formatting.
Logging Guidelines¶
Don’t use
std::coutorprintf, use spdlog instead.Use as many log messages as necessary but do not spam the log output with unnecessary entries either.
Use all log levels as you need it:
spdlog::trace,spdlog::info,spdlog::debug,spdlog::error,spdlog::critical.You can print variables with spdlog (see this reference) because it is based on fmt library.
Use direct API calls like
spdlog::debug("Example text here");instead of creating custom logger instance.