comparison OrthancFramework/Sources/HttpServer/HttpServer.cpp @ 5450:9ffd6d18daf3 pg-transactions

log lines now contain the thread name
author Alain Mazy <am@osimis.io>
date Tue, 05 Dec 2023 16:26:35 +0100
parents 0ea402b4d901
children 48b8dae6dc77
comparison
equal deleted inserted replaced
5449:29858f424fc7 5450:9ffd6d18daf3
1531 // We should never arrive at this point, where it is even impossible to send an answer 1531 // We should never arrive at this point, where it is even impossible to send an answer
1532 CLOG(ERROR, HTTP) << "Catastrophic error inside the HTTP server, giving up"; 1532 CLOG(ERROR, HTTP) << "Catastrophic error inside the HTTP server, giving up";
1533 } 1533 }
1534 } 1534 }
1535 1535
1536 static uint16_t threadCounter = 0;
1536 1537
1537 #if MONGOOSE_USE_CALLBACKS == 0 1538 #if MONGOOSE_USE_CALLBACKS == 0
1538 static void* Callback(enum mg_event event, 1539 static void* Callback(enum mg_event event,
1539 struct mg_connection *connection, 1540 struct mg_connection *connection,
1540 const struct mg_request_info *request) 1541 const struct mg_request_info *request)
1554 1555
1555 #elif MONGOOSE_USE_CALLBACKS == 1 1556 #elif MONGOOSE_USE_CALLBACKS == 1
1556 static int Callback(struct mg_connection *connection) 1557 static int Callback(struct mg_connection *connection)
1557 { 1558 {
1558 const struct mg_request_info *request = mg_get_request_info(connection); 1559 const struct mg_request_info *request = mg_get_request_info(connection);
1560
1561 if (!Logging::HasCurrentThreadName())
1562 {
1563 Logging::SetCurrentThreadName(std::string("HTTP-") + boost::lexical_cast<std::string>(threadCounter++));
1564 }
1559 1565
1560 ProtectedCallback(connection, request); 1566 ProtectedCallback(connection, request);
1561 1567
1562 return 1; // Do not let Mongoose handle the request by itself 1568 return 1; // Do not let Mongoose handle the request by itself
1563 } 1569 }
1641 return port_; 1647 return port_;
1642 } 1648 }
1643 1649
1644 void HttpServer::Start() 1650 void HttpServer::Start()
1645 { 1651 {
1652 // reset thread counter used to generate HTTP thread names.
1653 threadCounter = 0;
1654
1646 #if ORTHANC_ENABLE_MONGOOSE == 1 1655 #if ORTHANC_ENABLE_MONGOOSE == 1
1647 CLOG(INFO, HTTP) << "Starting embedded Web server using Mongoose"; 1656 CLOG(INFO, HTTP) << "Starting embedded Web server using Mongoose";
1648 #elif ORTHANC_ENABLE_CIVETWEB == 1 1657 #elif ORTHANC_ENABLE_CIVETWEB == 1
1649 CLOG(INFO, HTTP) << "Starting embedded Web server using Civetweb"; 1658 CLOG(INFO, HTTP) << "Starting embedded Web server using Civetweb";
1650 #else 1659 #else