Repository navigation
Conversation
Reuse the shared append backend and mutex for owned file output. Preserve other outputs on close and recover coherently from failed startup replay.
Accept an owned file path through the C API and C++ wrapper, and migrate the example and in-tree callers together. File output retains the shared logger synchronous, best-effort semantics.
Exercise public path, ownership, replay, filtering, and concurrent-close boundaries. Check appended logging and early log-open failure in the chainstate example.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36197. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where comparison-specific test macros should replace generic comparisons:
No Python comparison macro suggestions were found. 2026-09-09 07:29:03 |
|
Concept NACK. This increases coupling with Additionally, both concerns can be addressed by improving the implementation, e.g. less locking, logging on separate threads, etc. |
|
I agree with stickies-v here. It seems fine to give the responsibility of "block the logging callback for as little time as possible" to the consuming developer. |
|
Thanks for the review @stickies-v @sedited I opened this PR while working on asynchronous block processing, but found another approach that does not require this logging API change, so I’m closing this PR. I still think that the invoking application callbacks while holding internal locks can be a design hazard (Ex: CP.22: Never call unknown code while holding a lock (e.g., a callback). But this can be discussed separately. |
Kernel logging currently invokes application handlers while holding the logger mutex and, in some cases, validation locks. Slow handlers delay the caller, and handlers that call back into the kernel or acquire conflicting locks can deadlock.
This PR replaces those callbacks with the file writer already used by the node. Applications provide a file path through the C API or C++ wrapper, and the existing logger appends messages to that file. A single logging connection owns the file and closes it when destroyed.
This keeps application log handling out of kernel execution while reusing Core’s existing file writer and bounded startup buffer. It also avoids adding a separate delivery queue with its own capacity, overflow, and consumer lifecycle concerns. Applications can read the file independently and forward messages elsewhere.
File output keeps the node’s existing logging behavior: synchronous, best-effort writes with bounded startup buffering.