soulsmods / ModEngine2

Runtime injection library for modding Souls games. WIP
MIT License
864 stars 157 forks source link

Flush logs aggressively in debug mode #157

Open nex3 opened 10 months ago

nex3 commented 10 months ago

This comes from a similar motivation to #156: trying to debug a new extension that's simply crashing. Logs currently get written according to the underlying filesystem API's internal buffering logic, which means that data can be lost during a crash—particularly logs that happen immediately leading up to the crash, which are usually the most important for debugging.

I believe this can be handled fairly easily by setting logger.flush_on(). Edit: Setting flush_on() manually doesn't seem to be sufficient... it may be necessary to build some sort of custom sink that closes and reopens the file each time 😕