Skip to content

Making sure output debug messages are \n terminated. #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

sherief
Copy link
Contributor

@sherief sherief commented Mar 16, 2025

Prior to this, debug output with no \n results in multiple calls to OutputDebugStringA() on Windows resulting in some very, very long lines in (for example) the Output window in Visual Studio's debugger. In Visual Studio's case, this is enough to degrade UI performance to unusable points.

Prior to this, debug output with no \n results in multiple calls to
OutputDebugStringA() on Windows resulting in some very, very long lines
in (for example) the Output window in Visual Studio's debugger. In Visual
Studio's case, this is enough to degrade UI performance to unusable points.
@sherief sherief force-pushed the fix-debug-newlines branch from af51da0 to a762bb4 Compare March 16, 2025 18:15
@flibitijibibo
Copy link
Member

Not a huge deal but if this can be moved to the Win32 platform that'll avoid some extra work in the SDL side which does this via SDL_Log.

@sherief
Copy link
Contributor Author

sherief commented Mar 16, 2025

totally fine by me - I was working on another PR that adds support for logging to callback (which I understand could be more intrusive and might not be suitable / approved for merge), so was wondering whether long term the right place for this would be the log function itself or the platform layers?

@sherief
Copy link
Contributor Author

sherief commented Mar 16, 2025

#376

if you think that's a good idea I wouldn't mind modifying the SDL backend to remove its \n insertion - would that be okay?

@flibitijibibo
Copy link
Member

The weird thing in this case is that SDL sanitizes the end so that it both adds a new line when no new line is present, but also preserves 1 or more newlines if they're already present:

Newline cutoff: https://github.com/libsdl-org/SDL/blob/main/src/SDL_log.c#L613

Newline guarantee: https://github.com/libsdl-org/SDL/blob/main/src/SDL_log.c#L645

So we may just have to rip off SDL here and snprintf in Win32.c if we want it to be consistent. (I should probably document FNA3D to mention this, we follow the same behavior there as a result...)

@sherief
Copy link
Contributor Author

sherief commented Mar 16, 2025

okay, that makes sense - thanks for clearing this up. I think this PR should be closed without merging now.

@sherief sherief closed this Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants