Skip to content

Replace printf with SDL_Log variants

Johannes Marbach requested to merge cherrypicker/osk-sdl:feature/sdllog into master

All usages of printf were migrated to SDL_Log functions. This allows the log verbosity to be controlled centrally and the -v flag is only used once for setting the global priority threshold.

Error messages printed before exit were upgraded to the critical log priority. This automatically makes them print out on STDERR without setting the global priority threshold to error (critical is the default threshold in all categories except for the application category where info is the default threshold).

Error messages other than the last before calling exit were kept at the error log priority. This way only a single critical message is printed before exiting and further details show up when running with -v.

Closes: #107 (closed)

Example of log messages with these changes applied:

$ ./bin/osk-sdl -t
CRITICAL: No valid config file specified, use -c [path]
$ ./bin/osk-sdl -t -v
ERROR: Could not open config file: /etc/osk.conf
CRITICAL: No valid config file specified, use -c [path]

This turned out to be a little more subtle than just string-replacing the printf calls. I wasn't always sure what the best log category would be. Curious what others think of my choices.

Merge request reports