Skip to content

Commit 9837b7d

Browse files
authored
DEBUG or SYSLOG testing
1 parent 02ada4d commit 9837b7d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/httpserver_extension.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
385385
string host_str = host.GetString();
386386

387387
const char* debug_env = std::getenv("DUCKDB_HTTPSERVER_DEBUG");
388+
const char* use_syslog = std::getenv("DUCKDB_HTTPSERVER_SYSLOG");
389+
388390
if (debug_env != nullptr && std::string(debug_env) == "1") {
389391
global_state.server->set_logger([](const duckdb_httplib_openssl::Request& req, const duckdb_httplib_openssl::Response& res) {
390392
auto now = std::chrono::system_clock::now();
@@ -396,6 +398,17 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
396398
res.status);
397399
fflush(stdout);
398400
});
401+
} else if (use_syslog != nullptr && std::string(use_syslog) == "1") {
402+
openlog("duckdb-httpserver", LOG_PID | LOG_NDELAY, LOG_LOCAL0);
403+
global_state.server->set_logger([](const duckdb_httplib_openssl::Request& req, const duckdb_httplib_openssl::Response& res) {
404+
syslog(LOG_INFO, "%s %s - %d",
405+
req.method.c_str(),
406+
req.path.c_str(),
407+
res.status);
408+
});
409+
std::atexit([]() {
410+
closelog();
411+
});
399412
}
400413

401414
const char* run_in_same_thread_env = std::getenv("DUCKDB_HTTPSERVER_FOREGROUND");

0 commit comments

Comments
 (0)