Squashed 'src/ipc/libmultiprocess/' changes from 1b8d4a6f1e54..13424cf2ecc1

13424cf2ecc1 Merge bitcoin-core/libmultiprocess#205: cmake: check for Cap'n Proto / Clang / C++20 incompatibility
72dce118649b Merge bitcoin-core/libmultiprocess#200: event loop: add LogOptions struct and reduce the log size
85003409f964 eventloop: add `LogOptions` struct
657d80622f81 cmake: capnproto pkg missing helpful error
d314057775a5 cmake: check for Cap'n Proto / Clang / C++20 incompatibility
878e84dc3030 Merge bitcoin-core/libmultiprocess#203: cmake: search capnproto in package mode only
1a85da5873c2 Merge bitcoin-core/libmultiprocess#202: doc: correct the build instructions for the example
df01873e1ecb Merge bitcoin-core/libmultiprocess#197: ci: Add freebsd and macos build
3bee07ab3367 cmake: search capnproto in package mode only
b6d3dc44194c doc: correct the build instructions for example
fa1ac3000055 ci: Add macos and freebsd task

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 13424cf2ecc1e5eadc85556cf1f4c65e915f702a
This commit is contained in:
Ryan Ofsky
2025-09-05 15:43:16 -04:00
parent dd68d0f40b
commit a334bbe9b7
10 changed files with 129 additions and 23 deletions

View File

@@ -187,9 +187,9 @@ EventLoop::EventLoop(const char* exe_name, LogFn log_fn, void* context)
: m_exe_name(exe_name),
m_io_context(kj::setupAsyncIo()),
m_task_set(new kj::TaskSet(m_error_handler)),
m_log_fn(std::move(log_fn)),
m_context(context)
{
m_log_opts.log_fn = log_fn;
int fds[2];
KJ_SYSCALL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
m_wait_fd = fds[0];

View File

@@ -76,12 +76,11 @@ std::string ThreadName(const char* exe_name)
return std::move(buffer).str();
}
std::string LogEscape(const kj::StringTree& string)
std::string LogEscape(const kj::StringTree& string, size_t max_size)
{
const int MAX_SIZE = 1000;
std::string result;
string.visit([&](const kj::ArrayPtr<const char>& piece) {
if (result.size() > MAX_SIZE) return;
if (result.size() > max_size) return;
for (const char c : piece) {
if (c == '\\') {
result.append("\\\\");
@@ -92,7 +91,7 @@ std::string LogEscape(const kj::StringTree& string)
} else {
result.push_back(c);
}
if (result.size() > MAX_SIZE) {
if (result.size() > max_size) {
result += "...";
break;
}