Skip to content

Commit 02ada4d

Browse files
authored
Sketch Logger
untested sketch for logger hook. ideally we should provide options to pipe into a file and/or insert into a table, etc.
1 parent 6008ce1 commit 02ada4d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/httpserver_extension.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,20 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
384384

385385
string host_str = host.GetString();
386386

387+
const char* debug_env = std::getenv("DUCKDB_HTTPSERVER_DEBUG");
388+
if (debug_env != nullptr && std::string(debug_env) == "1") {
389+
global_state.server->set_logger([](const duckdb_httplib_openssl::Request& req, const duckdb_httplib_openssl::Response& res) {
390+
auto now = std::chrono::system_clock::now();
391+
auto now_time = std::chrono::system_clock::to_time_t(now);
392+
fprintf(stdout, "[%s] %s %s - %d\n",
393+
std::ctime(&now_time),
394+
req.method.c_str(),
395+
req.path.c_str(),
396+
res.status);
397+
fflush(stdout);
398+
});
399+
}
400+
387401
const char* run_in_same_thread_env = std::getenv("DUCKDB_HTTPSERVER_FOREGROUND");
388402
bool run_in_same_thread = (run_in_same_thread_env != nullptr && std::string(run_in_same_thread_env) == "1");
389403

0 commit comments

Comments
 (0)