diff --git a/CMakeLists.txt b/CMakeLists.txt index aac9f1df..1d58bdd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,172 +111,96 @@ endif() set(api_module ${lithium_src_dir}/client/astap.cpp - ${lithium_src_dir}/client/astap.hpp - ${lithium_src_dir}/client/astrometry.cpp - ${lithium_src_dir}/client/astrometry.hpp - ${lithium_src_dir}/client/phd2client.cpp - ${lithium_src_dir}/client/phd2client.hpp - ${lithium_module_dir}/client/indiclient.cpp - ${lithium_module_dir}/client/indiclient.hpp - ${lithium_src_dir}/client/hydrogen/hydrogencamera.cpp - ${lithium_src_dir}/client/hydrogen/hydrogencamera.hpp ) set(config_module ${lithium_module_dir}/config/configor.cpp - ${lithium_module_dir}/config/configor.hpp ) set(device_module ${lithium_module_dir}/device/device_manager.cpp - ${lithium_module_dir}/device/device_manager.hpp - ${lithium_module_dir}/device/indidevice_manager.cpp - ${lithium_module_dir}/device/indidevice_manager.hpp - ${lithium_module_dir}/device/device_utils.cpp - ${lithium_module_dir}/device/device_utils.hpp - ${lithium_module_dir}/device/indi_device.cpp - ${lithium_module_dir}/device/indi_device.hpp - ${lithium_module_dir}/device/hydrogen_device.cpp - ${lithium_module_dir}/device/hydrogen_device.hpp ) set(image_module ${lithium_src_dir}/image/image.cpp - ${lithium_src_dir}/image/image.hpp - ${lithium_src_dir}/image/draw.cpp ) set(io_module ${lithium_module_dir}/io/compress.cpp - ${lithium_module_dir}/io/compress.hpp - ${lithium_module_dir}/io/file.cpp - ${lithium_module_dir}/io/file.hpp - - ${lithium_module_dir}/io/glob.hpp - ${lithium_module_dir}/io/io.cpp - ${lithium_module_dir}/io/io.hpp -) - -set(launcher_module - ${lithium_src_dir}/launcher/crash.cpp - ${lithium_src_dir}/launcher/crash.hpp ) set(module_module ${lithium_module_dir}/module/modloader.cpp - ${lithium_module_dir}/module/modloader.hpp - ${lithium_module_dir}/plugin/plugin.cpp - ${lithium_module_dir}/plugin/plugin.hpp - ${lithium_module_dir}/plugin/exe_plugin.cpp - ${lithium_module_dir}/plugin/exe_plugin.hpp - ${lithium_module_dir}/plugin/script_plugin.cpp - ${lithium_module_dir}/plugin/script_plugin.hpp - ${lithium_module_dir}/plugin/plugin_manager.cpp - ${lithium_module_dir}/plugin/plugin_manager.hpp - ${lithium_module_dir}/module/compiler.cpp - ${lithium_module_dir}/module/compiler.hpp ) -set(network_module +set(web_module ${lithium_module_dir}/web/downloader.cpp - ${lithium_module_dir}/web/downloader.hpp - ${lithium_module_dir}/web/httpclient.cpp - ${lithium_module_dir}/web/httpclient.hpp - + ${lithium_module_dir}/web/httplite.cpp ${lithium_module_dir}/web/utils.cpp - ${lithium_module_dir}/web/utils.hpp - - # ${lithium_src_dir}/network/time.cpp - # ${lithium_src_dir}/network/time.hpp + ${lithium_module_dir}/web/time.cpp ) set(server_module ${lithium_module_dir}/server/commander.hpp ${lithium_module_dir}/server/message_bus.hpp ${lithium_module_dir}/server/message_queue.hpp - ${lithium_module_dir}/server/serialize.cpp - ${lithium_module_dir}/server/serialize.hpp ${lithium_src_dir}/websocket/WebSocketServer.cpp - ${lithium_src_dir}/websocket/WebSocketServer.hpp ${lithium_src_dir}/websocket/WsDeviceComponent.cpp ${lithium_src_dir}/websocket/WsProcessComponent.cpp ${lithium_src_dir}/websocket/WsScriptComponent.cpp ${lithium_src_dir}/websocket/WsTaskComponent.cpp ${lithium_src_dir}/websocket/device/WsDeviceHub.cpp - ${lithium_src_dir}/websocket/device/WsDeviceHub.hpp - ${lithium_src_dir}/websocket/device/WsDeviceInstance.cpp - ${lithium_src_dir}/websocket/device/WsDeviceInstance.hpp - ${lithium_src_dir}/websocket/device/WsDeviceServer.cpp - ${lithium_src_dir}/websocket/device/WsDeviceServer.hpp ${lithium_src_dir}/websocket/plugin/WsPluginHub.cpp - ${lithium_src_dir}/websocket/plugin/WsPluginHub.hpp - ${lithium_src_dir}/websocket/plugin/WsPluginInstance.cpp - ${lithium_src_dir}/websocket/plugin/WsPluginInstance.hpp - ${lithium_src_dir}/websocket/plugin/WsPluginServer.cpp - ${lithium_src_dir}/websocket/plugin/WsPluginServer.hpp ) set(script_module ${lithium_module_dir}/script/script_manager.cpp - ${lithium_module_dir}/script/script_manager.hpp ) set(task_module ${lithium_module_dir}/task/task_manager.cpp - ${lithium_module_dir}/task/task_manager.hpp - ${lithium_module_dir}/task/task_stack.cpp - ${lithium_module_dir}/task/task_stack.hpp - ${lithium_module_dir}/task/task_generator.cpp - ${lithium_module_dir}/task/task_generator.hpp ) set(thread_module ${lithium_module_dir}/thread/thread.cpp - ${lithium_module_dir}/thread/thread.hpp + ${lithium_module_dir}/thread/thread_pool.hpp ) set(system_module ${lithium_module_dir}/system/system.cpp - ${lithium_module_dir}/system/system.hpp - ${lithium_module_dir}/system/crash.cpp - ${lithium_module_dir}/system/crash.hpp - ${lithium_module_dir}/system/process.cpp - ${lithium_module_dir}/system/process.hpp - ${lithium_module_dir}/system/pid.cpp - ${lithium_module_dir}/system/pid.hpp - - ${lithium_module_dir}/system/pidw.cpp ${lithium_module_dir}/system/pidw.cpp + ${lithium_module_dir}/system/filew.cpp + ${lithium_module_dir}/system/dirw.cpp ) set(utils_module @@ -286,14 +210,10 @@ set(utils_module ) set(Lithium_module - ${lithium_src_dir}/ErrorHandler.cpp - ${lithium_src_dir}/ErrorHandler.hpp - ${lithium_src_dir}/App.cpp ${lithium_src_dir}/AppComponent.hpp - + ${lithium_src_dir}/ErrorHandler.cpp ${lithium_src_dir}/LithiumApp.cpp - ${lithium_src_dir}/LithiumApp.hpp ) find_package(OpenSSL REQUIRED) @@ -314,7 +234,7 @@ include(cmake_modules/Gettext_helpers.cmake) configure_gettext( DOMAIN "lithium" TARGET_NAME "lithium-gettext" - SOURCES "${api_module}" "${config_module}" "${io_module}" "${module_module}" "${network_module}" "${device_module}" "${thread_module}" "${task_module}" "${server_module}" "${script_module}" "${system_module}" "${Lithium_module}" + SOURCES "${api_module}" "${config_module}" "${io_module}" "${module_module}" "${web_module}" "${device_module}" "${thread_module}" "${task_module}" "${server_module}" "${script_module}" "${system_module}" "${Lithium_module}" POTFILE_DESTINATION "locale" XGETTEXT_ARGS "--keyword=_" "--keyword=N_" "--keyword=P_:1,2" @@ -358,7 +278,7 @@ if(NOT WIN32) add_subdirectory(${lithium_module_dir}/deviceloader) endif() -add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${network_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${utils_module} ${Lithium_module}) +add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${web_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${utils_module} ${Lithium_module}) target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs) diff --git a/locale/lithium.pot b/locale/lithium.pot new file mode 100644 index 00000000..0b2cacce --- /dev/null +++ b/locale/lithium.pot @@ -0,0 +1,259 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Max Qian +# This file is distributed under the same license as the package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: astro_air@126.com\n" +"POT-Creation-Date: 2023-11-03 22:24+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/device/device_manager.cpp:161 +msgid "A device with name {} already exists, please choose a different name" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/device/indidevice_manager.cpp:266 +msgid "Failed to run command: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:63 +msgid "Failed to destroy ThreadManager: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:82 +msgid "Thread manager has stopped, cannot add new thread" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:100 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:122 +msgid "Unhandled exception in thread: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:128 +msgid "Added thread: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:133 +msgid "Failed to add thread {}: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:149 +msgid "All threads joined" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:153 +msgid "Failed to join all threads: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:163 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:180 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:194 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:205 +msgid "Thread {} not found" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:172 +msgid "Thread {} joined" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:184 +msgid "Failed to join thread {}: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/thread/thread.cpp:210 +msgid "Failed to check if thread {} is running: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:76 +msgid "Failed to create PowerShell process" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:86 +msgid "Running command: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:103 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:127 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:148 +msgid "Failed to create process" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:113 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:158 +msgid "Process created: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:137 +msgid "Running script: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:175 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:187 +msgid "Process terminated: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:179 +msgid "Failed to terminate process" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:195 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:240 +msgid "Process not found" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:210 +msgid "Process not found by name: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:255 +msgid "Process completed: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:259 +msgid "Failed to wait for process completion" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:265 +#, c-format +msgid "Process completed: %s (PID: %d)" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:270 +msgid "All processes completed." +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:281 +msgid "Failed to create process snapshot" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:322 +msgid "Failed to open /proc directory" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:351 +msgid "Failed to get process path" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:372 +msgid "Failed to get process info length" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:379 +msgid "Failed to allocate memory" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:385 +msgid "Failed to get process info" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:94 +msgid "CreateToolhelp32Snapshot failed." +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:113 +msgid "Watching process with PID: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:124 +msgid "Process exited with code: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:133 +msgid "GetExitCodeProcess failed." +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:143 +msgid "OpenProcess failed." +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:170 +msgid "Process exited with status: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/pid.cpp:179 +msgid "Process terminated by signal: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:226 +msgid "port the server running on" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:227 +msgid "host the server running on" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:228 +msgid "path to the config file" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:229 +msgid "path to the modules directory" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:230 +msgid "web panel" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:231 +msgid "path to log file" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:233 +msgid "Lithium Command Line Interface:" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:234 +msgid "End." +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:242 +#, c-format +msgid "Failed to parser command line : %s" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:263 +#, c-format +msgid "Command line server port : %d" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:269 +#, c-format +msgid "Set server port to %d" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:81 +msgid "Failed to load Lithium App , error : {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:93 +msgid "Get config value: {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:99 +msgid "Set {} to {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:286 +msgid "Failed to run chai command : {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:304 +msgid "Failed to run chai multi command {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:317 +msgid "Failed to load chaiscript file {}" +msgstr "" + +#: E:/msys64/home/Qrm/OpenAPT/src/LithiumApp.cpp:330 +msgid "Failed to run chai script {}" +msgstr "" diff --git a/src/modules/web/time.cpp b/src/modules/web/time.cpp index 33db9105..17da6e19 100644 --- a/src/modules/web/time.cpp +++ b/src/modules/web/time.cpp @@ -54,7 +54,7 @@ Description: Time #include #endif -#include +// #include namespace Lithium::Time { @@ -76,11 +76,11 @@ namespace Lithium::Time sysTime.wSecond = second; if (!SetSystemTime(&sysTime)) { - spdlog::error("Failed to set system time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}. Error code: {}", year, month, day, hour, minute, second, GetLastError()); + // spdlog::error("Failed to set system time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}. Error code: {}", year, month, day, hour, minute, second, GetLastError()); } else { - DLOG_F(INFO,"System time has been set to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); + DLOG_F(INFO, "System time has been set to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); } } @@ -92,23 +92,23 @@ namespace Lithium::Time DWORD tz_id; if (!GetTimeZoneInformationByName(timezone, &tz_id)) { - spdlog::error("Error getting time zone id for {}: {}", timezone, GetLastError()); + // spdlog::error("Error getting time zone id for {}: {}", timezone, GetLastError()); success = false; } TIME_ZONE_INFORMATION tz_info; if (!GetTimeZoneInformation(&tz_info)) { - spdlog::error("Error getting current time zone information: {}", GetLastError()); + // spdlog::error("Error getting current time zone information: {}", GetLastError()); success = false; } else if (tz_info.StandardBias != -static_cast(tz_id)) { - spdlog::error("Time zone id obtained does not match offset: {} != {}", tz_id, -tz_info.StandardBias); + // spdlog::error("Time zone id obtained does not match offset: {} != {}", tz_id, -tz_info.StandardBias); success = false; } if (!SetTimeZoneInformation(&tz_info)) { - spdlog::error("Error setting time zone to {}: {}", timezone, GetLastError()); + // spdlog::error("Error setting time zone to {}: {}", timezone, GetLastError()); success = false; } return success; @@ -219,7 +219,7 @@ namespace Lithium::Time { if (geteuid() != 0) { - spdlog::error("Permission denied. Need root privilege to set system time."); + // spdlog::error("Permission denied. Need root privilege to set system time."); return; } @@ -235,17 +235,17 @@ namespace Lithium::Time if (std::mktime(&new_time) == -1) { - spdlog::error("Failed to set new time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); + // spdlog::error("Failed to set new time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); return; } if (std::abs(std::difftime(now, std::mktime(&new_time))) < 2) { - DLOG_F(INFO,"System time has been set to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); + DLOG_F(INFO, "System time has been set to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); } else { - spdlog::error("Failed to set new time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); + // spdlog::error("Failed to set new time to {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.", year, month, day, hour, minute, second); } } @@ -256,13 +256,13 @@ namespace Lithium::Time memset(&new_time, 0, sizeof(new_time)); if (strptime("20200101", "%Y%m%d", &new_time) == NULL) { - spdlog::error("Failed to initialize struct tm."); + // spdlog::error("Failed to initialize struct tm."); success = false; } tzset(); if (setenv("TZ", timezone.c_str(), 1) != 0) { - spdlog::error("Error setting time zone to {}: {}", timezone, strerror(errno)); + // spdlog::error("Error setting time zone to {}: {}", timezone, strerror(errno)); success = false; } else @@ -270,7 +270,7 @@ namespace Lithium::Time tzset(); if (strftime(NULL, 0, "%Z", &new_time) == 0) { - spdlog::error("Error setting time zone to {}: {}", timezone, strerror(errno)); + // spdlog::error("Error setting time zone to {}: {}", timezone, strerror(errno)); success = false; } } @@ -286,18 +286,18 @@ namespace Lithium::Time struct stat rtc_stat; if (stat(rtc_path, &rtc_stat) != 0) { - spdlog::error("Failed to stat RTC file: {}", strerror(errno)); + // spdlog::error("Failed to stat RTC file: {}", strerror(errno)); return false; } if (!S_ISREG(rtc_stat.st_mode)) { - spdlog::error("RTC path is not a regular file"); + // spdlog::error("RTC path is not a regular file"); return false; } std::ifstream rtc_file(rtc_path); if (!rtc_file.is_open()) { - spdlog::error("Failed to open RTC file: {}", strerror(errno)); + // spdlog::error("Failed to open RTC file: {}", strerror(errno)); return false; } int year, month, day, hour, minute, second; @@ -330,12 +330,12 @@ namespace Lithium::Time } if (tv.tv_sec < now - 60 || tv.tv_sec > now + 60) { - spdlog::error("RTC time is too far away from current time"); + // spdlog::error("RTC time is too far away from current time"); return false; // 如果调整后的时间与当前时间相差超过1分钟,则认为调整失败 } if (settimeofday(&tv, nullptr) != 0) { - spdlog::error("Failed to adjust system time: {}", strerror(errno)); + // spdlog::error("Failed to adjust system time: {}", strerror(errno)); return false; } @@ -354,7 +354,7 @@ namespace Lithium::Time WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { - spdlog::error("Failed to initialize Winsock2."); + // spdlog::error("Failed to initialize Winsock2."); return 0; } #endif @@ -363,7 +363,7 @@ namespace Lithium::Time int socketFd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (socketFd < 0) { - spdlog::error("Failed to create socket."); + // spdlog::error("Failed to create socket."); return 0; } @@ -387,7 +387,7 @@ namespace Lithium::Time if (sendto(socketFd, (char *)packetBuffer, NTP_PACKET_SIZE, 0, (sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) { - spdlog::error("Failed to send NTP request: {}", strerror(errno)); + // spdlog::error("Failed to send NTP request: {}", strerror(errno)); return 0; } @@ -398,7 +398,7 @@ namespace Lithium::Time FD_SET(socketFd, &readfds); if (select(socketFd + 1, &readfds, nullptr, nullptr, &timeout) <= 0) { - spdlog::error("Failed to receive NTP response: {}", strerror(errno)); + // spdlog::error("Failed to receive NTP response: {}", strerror(errno)); return 0; } @@ -409,7 +409,7 @@ namespace Lithium::Time if (recvfrom(socketFd, (char *)packetBuffer, NTP_PACKET_SIZE, 0, (sockaddr *)&serverResponseAddr, &addrLen) < 0) { - spdlog::error("Failed to receive NTP response: {}", strerror(errno)); + // spdlog::error("Failed to receive NTP response: {}", strerror(errno)); return 0; } @@ -428,7 +428,7 @@ namespace Lithium::Time timestamp -= 2208988800UL; // 将从 1900 年至今的秒数转换为从 1970 年至今的秒数 - DLOG_F(INFO,"从 {} 获取到的时间戳是:{}", hostname, timestamp); + DLOG_F(INFO, "从 {} 获取到的时间戳是:{}", hostname, timestamp); return (time_t)timestamp; } @@ -438,7 +438,7 @@ namespace Lithium::Time /* int main() { // Initialize spdlog logger - auto logger = spdlog::stdout_color_mt("console"); + auto logger = //spdlog::stdout_color_mt("console"); // Test the function on Windows and Linux std::string timezone = "Asia/Shanghai";