Repository navigation
Keep one logger for the whole process - #145
Merged
Merged
Conversation
trypsynth
force-pushed
the
fix/single-logger
branch
from
September 26, 2026 22:28
b07b3a8 to
661e30f
Compare
Since 7b78f08, logger() returns `new Logger` on every call instead of a single static instance. Each call to prism_set_log_level, prism_set_log_handler and prism_log, and every message a backend logs, gets a logger of its own. The level and handler never reach the logger a message goes to, so nothing is delivered. Each Logger also starts a drain thread that never stops, so every call leaks a thread. The lambda keeps the behavior 7b78f08 introduced of returning nullptr when allocation fails instead of throwing. Signed-off-by: Quin Gillespie <[email protected]>
trypsynth
force-pushed
the
fix/single-logger
branch
from
September 27, 2026 02:24
661e30f to
1cf6cc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 7b78f08, logging has been broken for me:
prism_set_log_levelreturnsPRISM_LOG_LEVEL_NONEinstead of the previous level.prism_set_log_handlernever receives a message, because each message goes to a new logger.Loggerstarts a drain thread that never stops, so every call leaks a thread.I made it so
logger()creates the logger once, in a function-local static that a lambda initializes. Your commit did actually address something that seems legit to me, so the lambda does returnnullptrwhen allocation fails instead of throwing.Tested on x64 Windows 10. The following C program sets a handler and a level, logs 1000 messages, and counts its threads:
Before:
After: