2. Logging and Printing Messages to Console
Printing messages to the log file and console helps to monitor overall progress of execution of your application and report errors which can be used in debugging. Log class makes it possible to print formatted string messages to the log file and the console. The code below demonstrates how to print various types of messages:
// auxiliary variables for messages char *file_name = "file.txt"; int ID = 10; // reporting an error message Log::error("Loading mesh: can't open \"%s\" file\n", file_name); // reporting a message Log::message("-> Added %d UI elements.\n", 10); // reporting a warning message Log::warning("ID of the \"%s\" file: %d.\n", file_name, ID); // reporting a fatal error message to the log file and closing the application Log::fatal("FATAL ERROR reading \"%s\" file!\n", file_name);
- For more information on the console, see Console page.
- For more information on the Log class, see Log class page.