Skip to content
Snippets Groups Projects

Replace printf with SDL_Log variants

Merged Imported Administrator requested to merge feature/sdllog into master
All threads resolved!

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Administrator
  • Author Owner

    Thanks for taking this on!

    By clayton craft on 2020-12-06T03:13:28

  • Administrator
  • Administrator added 1 commit · Imported

    added 1 commit

    • eba8f133 - Replace printf with SDL_Log variants

    Compare with previous version

    By Johannes Marbach on 2020-12-07T18:38:43

  • Administrator added 1 commit · Imported

    added 1 commit

    • 6e15cf38 - Replace printf with SDL_Log variants

    Compare with previous version

    By Johannes Marbach on 2020-12-07T18:43:03

  • Administrator added 1 commit · Imported

    added 1 commit

    • 945a69eb - Replace printf with SDL_Log variants

    Compare with previous version

    By Johannes Marbach on 2020-12-07T18:48:31

  • Administrator approved this merge request · Imported

    approved this merge request

    By Alexey Min on 2020-12-07T18:53:03

  • Author Owner

    +1 if errors are always printed

    By Alexey Min on 2020-12-07T18:53:19

  • Administrator added 1 commit · Imported

    added 1 commit

    • 7941343c - Replace printf with SDL_Log variants (MR 108)

    Compare with previous version

    By clayton craft on 2020-12-08T00:40:50

  • Administrator approved this merge request · Imported

    approved this merge request

    By clayton craft on 2020-12-08T00:41:18

  • Administrator resolved all threads · Imported

    resolved all threads

    By clayton craft on 2020-12-08T00:41:30

  • Administrator merged · Imported

    merged

  • Administrator mentioned in merge request !105 (merged) · Imported

    mentioned in merge request !105 (merged)

    By clayton craft on 2020-12-08T00:49:52

  • Administrator mentioned in merge request !104 (merged) · Imported

    mentioned in merge request !104 (merged)

    By Johannes Marbach on 2020-12-12T09:25:28

  • Please register or sign in to reply
    Loading