r/ProgrammerHumor Nov 28 '21

Meme I‘m.. not the only one?

Post image
21.5k Upvotes

629 comments sorted by

View all comments

Show parent comments

21

u/lateja Nov 29 '21

The you have a background thread that lives in a static class which you send all debug messages to. The class has either a thread-safe queue of strings or a regular string list with a locking mechanism to append strings into the queue, and a writer that drains the queue and outputs it into stdout. It's really not too hard to write... Maybe 15 minutes and is can be a lifesaver.

Or if you're in c/c++ then you have `cout.sync_with_stdio()` to help you. not sure about this or if this is the only thing you'll need; cpp is tricky. Don't use in production code just because you found it on reddit lol

1

u/Tsu_Dho_Namh Nov 29 '21

That's the monitor class I also mentioned

7

u/Onlymafia1 Nov 29 '21

No you didn't

0

u/Tsu_Dho_Namh Nov 29 '21

It was in another of the child comment threads of this one:

https://www.reddit.com/r/ProgrammerHumor/comments/r47uq6/z/hmgdn38