[win-linux] updatesvc: log formatting and version output

This commit is contained in:
SimplestStudio
2025-06-16 17:53:24 +03:00
parent c3754fe39a
commit 83f223e067
4 changed files with 13 additions and 5 deletions

View File

@ -45,6 +45,7 @@
#define DECL_VERSION __attribute__((section(".version_info"), unused))
volatile static const char DECL_VERSION version[] = VER_STRING;
static const char gSvcVersion[] = "Service version: " VER_STRING;
void strToNum(const char *str, int &num)
{
@ -59,8 +60,10 @@ int main(int argc, char *argv[])
if (argc > 1) {
if (strcmp(argv[1], "--run-as-app") == 0) {
NS_Utils::parseCmdArgs(argc, argv);
if (NS_Utils::cmdArgContains("--log"))
if (NS_Utils::cmdArgContains("--log")) {
NS_Logger::AllowWriteLog();
NS_Logger::WriteLog(gSvcVersion);
}
std::locale::global(std::locale(""));
Translator lang(NS_Utils::GetAppLanguage(), "/langs/langs.iss");
CSocket socket(0, INSTANCE_SVC_PORT);

View File

@ -613,7 +613,7 @@ namespace NS_Logger
if (!file.is_open()) {
return;
}
file << log << std::endl;
file << log << string("\n") << std::endl;
file.close();
}
if (showMessage)

View File

@ -44,6 +44,7 @@
SERVICE_STATUS gSvcStatus;
SERVICE_STATUS_HANDLE gSvcStatusHandle;
HANDLE gSvcStopEvent = NULL;
static const WCHAR gSvcVersion[] = _T("Service version: " VER_STRING);
VOID WINAPI SvcMain(DWORD argc, LPTSTR *argv);
@ -99,8 +100,10 @@ int __cdecl _tmain (int argc, TCHAR *argv[])
if (lstrcmpi(argv[1], _T("--run-as-app")) == 0) {
NS_Utils::setRunAsApp();
NS_Utils::parseCmdArgs(argc, argv);
if (NS_Utils::cmdArgContains(_T("--log")))
if (NS_Utils::cmdArgContains(_T("--log"))) {
NS_Logger::AllowWriteLog();
NS_Logger::WriteLog(gSvcVersion);
}
std::locale::global(std::locale(""));
Translator lang(NS_Utils::GetAppLanguage().c_str(), IDT_TRANSLATIONS);
CSocket socket(0, INSTANCE_SVC_PORT);
@ -162,8 +165,10 @@ int __cdecl _tmain (int argc, TCHAR *argv[])
VOID WINAPI SvcMain(DWORD argc, LPTSTR *argv)
{
NS_Utils::parseCmdArgs(argc, argv);
if (NS_Utils::cmdArgContains(_T("--log")))
if (NS_Utils::cmdArgContains(_T("--log"))) {
NS_Logger::AllowWriteLog();
NS_Logger::WriteLog(gSvcVersion);
}
gSvcStatusHandle = RegisterServiceCtrlHandler(SERVICE_NAME, SvcCtrlHandler);
if (gSvcStatusHandle == NULL) {

View File

@ -723,7 +723,7 @@ namespace NS_Logger
if (!file.is_open()) {
return;
}
file << log << std::endl;
file << log << wstring(L"\n") << std::endl;
file.close();
}
if (showMessage)