mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-19 16:30:11 +01:00
switched to fprintf logging and to access_log
This commit is contained in:
parent
c8cedf5684
commit
a30d4b2a8f
@ -857,15 +857,25 @@ static void parse_options_completion(const json & body, llama_server_context & l
|
|||||||
LOG_VERBOSE("completion parameters parsed", format_generation_settings(llama));
|
LOG_VERBOSE("completion parameters parsed", format_generation_settings(llama));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void log_server_request(const Request & req, const Response & res) {
|
static void log_server_request(const Request & req, const Response & res) {
|
||||||
LOG_INFO("request", {
|
std::string referrer = req.has_header("Referer") ? req.get_header_value("Referer") : "-";
|
||||||
{ "remote_addr", req.remote_addr },
|
std::string user_agent = req.has_header("User-Agent") ? req.get_header_value("User-Agent") : "-";
|
||||||
{ "remote_port", req.remote_port },
|
std::time_t now = std::time(nullptr);
|
||||||
{ "status", res.status },
|
char time_str[80];
|
||||||
{ "path", req.path },
|
std::strftime(time_str, sizeof(time_str), "%d/%b/%Y:%H:%M:%S %z", std::localtime(&now));
|
||||||
{ "request", req.body },
|
|
||||||
// { "response", res.body },
|
fprintf(stdout, "%s - - [%s] \"%s %s HTTP/%s\" %d %zu \"%s\" \"%s\"\n",
|
||||||
});
|
req.remote_addr.c_str(),
|
||||||
|
time_str,
|
||||||
|
req.method.c_str(),
|
||||||
|
req.path.c_str(),
|
||||||
|
"1.1",
|
||||||
|
res.status,
|
||||||
|
res.body.size(),
|
||||||
|
referrer.c_str(),
|
||||||
|
user_agent.c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
@ -1070,20 +1080,16 @@ int main(int argc, char ** argv) {
|
|||||||
svr.set_read_timeout(sparams.read_timeout);
|
svr.set_read_timeout(sparams.read_timeout);
|
||||||
svr.set_write_timeout(sparams.write_timeout);
|
svr.set_write_timeout(sparams.write_timeout);
|
||||||
|
|
||||||
// Set the base directory for serving static files
|
|
||||||
svr.set_base_dir(sparams.public_path);
|
|
||||||
|
|
||||||
if (!svr.bind_to_port(sparams.hostname, sparams.port)) {
|
if (!svr.bind_to_port(sparams.hostname, sparams.port)) {
|
||||||
LOG_ERROR("couldn't bind to server socket", {
|
fprintf(stderr, "\ncouldn't bind to server socket: hostname=%s port=%d\n\n", sparams.hostname.c_str(), sparams.port);
|
||||||
{ "hostname", sparams.hostname },
|
|
||||||
{ "port", sparams.port },
|
|
||||||
});
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl;
|
// Set the base directory for serving static files
|
||||||
std::cout << "llama server listening at http://" << sparams.hostname << ":" << sparams.port << std::endl;
|
svr.set_base_dir(sparams.public_path);
|
||||||
std::cout << std::endl;
|
|
||||||
|
fprintf(stdout, "\nllama server listening at http://%s:%d\n\n", sparams.hostname.c_str(), sparams.port);
|
||||||
|
|
||||||
|
|
||||||
if (!svr.listen_after_bind()) {
|
if (!svr.listen_after_bind()) {
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user