Skip to content

Commit

Permalink
Sketch Logger
Browse files Browse the repository at this point in the history
untested sketch for logger hook. ideally we should provide options to pipe into a file and/or insert into a table, etc.
  • Loading branch information
lmangani authored Dec 3, 2024
1 parent 6008ce1 commit 02ada4d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/httpserver_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,20 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t

string host_str = host.GetString();

const char* debug_env = std::getenv("DUCKDB_HTTPSERVER_DEBUG");
if (debug_env != nullptr && std::string(debug_env) == "1") {
global_state.server->set_logger([](const duckdb_httplib_openssl::Request& req, const duckdb_httplib_openssl::Response& res) {
auto now = std::chrono::system_clock::now();
auto now_time = std::chrono::system_clock::to_time_t(now);
fprintf(stdout, "[%s] %s %s - %d\n",
std::ctime(&now_time),
req.method.c_str(),
req.path.c_str(),
res.status);
fflush(stdout);
});
}

const char* run_in_same_thread_env = std::getenv("DUCKDB_HTTPSERVER_FOREGROUND");
bool run_in_same_thread = (run_in_same_thread_env != nullptr && std::string(run_in_same_thread_env) == "1");

Expand Down

0 comments on commit 02ada4d

Please sign in to comment.