From 12e69da5fb61aedf0cc2526bc1ee906dd966b0e5 Mon Sep 17 00:00:00 2001 From: kkk <82047973+kkk-455123@users.noreply.github.com> Date: Sun, 10 Sep 2023 15:03:05 +0800 Subject: [PATCH] Update webserver.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit log日志库的初始化在socket初始化之后会造成日志无法记录socket初始化过程中的相关错误,因此commit中将日志初始化前移至socket初始化之前。 --- code/server/webserver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/server/webserver.cpp b/code/server/webserver.cpp index 9bad089..73f5c38 100644 --- a/code/server/webserver.cpp +++ b/code/server/webserver.cpp @@ -22,12 +22,14 @@ WebServer::WebServer( HttpConn::userCount = 0; HttpConn::srcDir = srcDir_; SqlConnPool::Instance()->Init("localhost", sqlPort, sqlUser, sqlPwd, dbName, connPoolNum); + if(openLog) { + Log::Instance()->init(logLevel, "./log", ".log", logQueSize); + } InitEventMode_(trigMode); if(!InitSocket_()) { isClose_ = true;} if(openLog) { - Log::Instance()->init(logLevel, "./log", ".log", logQueSize); if(isClose_) { LOG_ERROR("========== Server init error!=========="); } else { LOG_INFO("========== Server init ==========");