Merge pull request #16 from anon998/fix-log-json

Replace invalid characters instead of crashing.
This commit is contained in:
Randall Fitzgerald 2023-06-02 09:43:29 -04:00 committed by GitHub
commit 4dd72fc6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -995,7 +995,8 @@ int main(int argc, char **argv)
{ "request", req.body },
{ "response", res.body },
};
fprintf(stdout, "http_request: %s\n", log.dump().c_str());
fprintf(stdout, "http_request: %s\n",
log.dump(-1, ' ', false, json::error_handler_t::replace).c_str());
});
svr.set_exception_handler([](const Request &, Response &res, std::exception_ptr ep) {