Skip to content

Split SimpleLogger into facade and impl, reduce flush contention - #228

Merged
greensky00 merged 1 commit into
masterfrom
junahn_pr1
Nov 11, 2026
Merged

greensky00 merged 1 commit into
masterfrom
junahn_pr1

Conversation

@greensky00

Copy link
Copy Markdown
Contributor
  • Split SimpleLogger into a facade (logger.h) holding only an impl pointer, and SimpleLoggerImpl (logger_impl.h) holding all the state. A library compiled with a different copy of logger.h no longer depends on the logger's internal layout.

  • Make the accessors (getLogLevel(), traceAllowed(), etc.) and stream()/eos() non-inline, as they access the state.

  • Add an ABI version tag to the constructor's signature, so that code compiled with an incompatible header fails to link instead of corrupting memory.

  • addLogger() no longer waits for an ongoing flush pass. New loggers go to a pending list, which the flusher merges into the registry.

  • Add a per-logger dirty flag, so that the background flusher skips the ring buffer scan of loggers with no new logs.

  • Fix lost logs under heavy logging: a writer could give up on its entry while another thread was flushing it, or when another writer took the same entry after the cursor wrapped around. The writer now retries until the write succeeds.

* Split `SimpleLogger` into a facade (`logger.h`) holding only an
  `impl` pointer, and `SimpleLoggerImpl` (`logger_impl.h`) holding
  all the state. A library compiled with a different copy of
  `logger.h` no longer depends on the logger's internal layout.

* Make the accessors (`getLogLevel()`, `traceAllowed()`, etc.) and
  `stream()`/`eos()` non-inline, as they access the state.

* Add an ABI version tag to the constructor's signature, so that code
  compiled with an incompatible header fails to link instead of
  corrupting memory.

* `addLogger()` no longer waits for an ongoing flush pass. New loggers
  go to a pending list, which the flusher merges into the registry.

* Add a per-logger dirty flag, so that the background flusher skips
  the ring buffer scan of loggers with no new logs.

* Fix lost logs under heavy logging: a writer could give up on its
  entry while another thread was flushing it, or when another writer
  took the same entry after the cursor wrapped around. The writer now
  retries until the write succeeds.
@greensky00
greensky00 merged commit dc46348 into master Nov 11, 2026
1 check passed
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.

1 participant