Skip to content

Commit dcf3dcd

Browse files
committed
log_server_request: rm try catch, add reminder
1 parent 4247f3d commit dcf3dcd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

examples/server/server.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,14 +3353,12 @@ static void log_server_request(const httplib::Request & req, const httplib::Resp
33533353
return;
33543354
}
33553355

3356-
try {
3357-
LOG_INF("request: %s %s %s %d\n", req.method.c_str(), req.path.c_str(), req.remote_addr.c_str(), res.status);
3356+
// reminder: this function is not covered by httplib's exception handler; if someone does more complicated stuff, think about wrapping it in try-catch
33583357

3359-
LOG_DBG("request: %s\n", req.body.c_str());
3360-
LOG_DBG("response: %s\n", res.body.c_str());
3361-
} catch (const std::exception & e) {
3362-
LOG_ERR("failed to log request/response: %s\n", e.what());
3363-
}
3358+
LOG_INF("request: %s %s %s %d\n", req.method.c_str(), req.path.c_str(), req.remote_addr.c_str(), res.status);
3359+
3360+
LOG_DBG("request: %s\n", req.body.c_str());
3361+
LOG_DBG("response: %s\n", res.body.c_str());
33643362
}
33653363

33663364
std::function<void(int)> shutdown_handler;

0 commit comments

Comments
 (0)