Debug Logging with SDL

Hey all, I’m looking for a way to print debug output text using SDL 2.0.3, in a manner similar to the Windows API function OutputDebugString.

I’ve been experimenting with the SDL log functions, but I’m finding that the category/priority mechanism adds complications. I’d like to control categorization and priority myself where necessary so I really just want a function that takes a string and prints it to the debug output stream. Does anything like this exist?

If not, I can suppress the SDL category/priority system by wrapping them in a function that just passes all such messages to a given category with verbose (or some other) priority. The problem is then that all messages are prefixed with category/priority information, like “[INFO]” or “VERBOSE:”. Is it possible to prevent this?

Any advice would be greatly appreciated, thanks!

Take a look here:

http://wiki.libsdl.org/CategoryLog

In particular, you can assign your own log writing function using this:

http://wiki.libsdl.org/SDL_LogSetOutputFunction

In your log output callback, just write /message/ and ignore the other parameters. For instance, I’ve used a custom log output callback to write to
stdout and to log file.

AlvinOn 06/11/14 09:02, Jmuulian wrote:

Hey all, I’m looking for a way to print debug output text using SDL 2.0.3, in a manner similar to the Windows API function OutputDebugString.

I’ve been experimenting with the SDL log functions, but I’m finding that the category/priority mechanism adds complications. I’d like to control
categorization and priority myself where necessary so I really just want a function that takes a string and prints it to the debug output stream. Does
anything like this exist?

If not, I can suppress the SDL category/priority system by wrapping them in a function that just passes all such messages to a given category with
verbose (or some other) priority. The problem is then that all messages are prefixed with category/priority information, like “[INFO]” or “VERBOSE:”.
Is it possible to prevent this?

Any advice would be greatly appreciated, thanks!

Thanks for your response, but unless I’m mistaken that doesn’t solve my problem. I actually do want SDL to handle the platform-specific details of the logging output, just without the additional formatting and complications described above.

Ideally, what I’d like to access is the function which takes the result of the log formatting, and outputs it in the appropriate manner for that platform. This functionality exists in SDL, but appears not to be exposed in the library interface.

Have a look at these SDLTest functions (see include/SDL_test_log.h and
/src/test/SDL_test_log.c):

/**

  • \brief Prints given message with a timestamp in the TEST category
    and INFO priority.*
  • \param fmt Message to be logged
    */
    void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, …)
    SDL_PRINTF_VARARG_FUNC(1);

/**

  • \brief Prints given message with a timestamp in the TEST category
    and the ERROR priority.
  • \param fmt Message to be logged
    */
    void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, …)
    SDL_PRINTF_VARARG_FUNC(1);

On 11/6/2014 6:05 AM, Alvin Beach wrote:

On 06/11/14 09:02, Jmuulian wrote:

Hey all, I’m looking for a way to print debug output text using SDL 2.0.3, in a manner similar to the Windows API function OutputDebugString.

I’ve been experimenting with the SDL log functions, but I’m finding that the category/priority mechanism adds complications. I’d like to control
categorization and priority myself where necessary so I really just want a function that takes a string and prints it to the debug output stream. Does
anything like this exist?

If not, I can suppress the SDL category/priority system by wrapping them in a function that just passes all such messages to a given category with
verbose (or some other) priority. The problem is then that all messages are prefixed with category/priority information, like “[INFO]” or “VERBOSE:”.
Is it possible to prevent this?

Any advice would be greatly appreciated, thanks!
Take a look here:

http://wiki.libsdl.org/CategoryLog

In particular, you can assign your own log writing function using this:

http://wiki.libsdl.org/SDL_LogSetOutputFunction

In your log output callback, just write /message/ and ignore the other parameters. For instance, I’ve used a custom log output callback to write to
stdout and to log file.

Alvin


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org