解决linux系统记录日志混乱的问题

This commit is contained in:
luoliangyi 2024-08-23 10:49:37 +08:00
parent 4c8691bb4e
commit 5de0658d61
6 changed files with 84 additions and 66 deletions

View File

@ -50,18 +50,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif

View File

@ -43,18 +43,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif

View File

@ -43,18 +43,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif

View File

@ -56,18 +56,21 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/)
} }
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif

View File

@ -43,18 +43,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif

View File

@ -43,18 +43,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
#else #else
void __attribute__((constructor)) global_load(void); class LogMgr
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{ {
g_hLog = EnableLog(nullptr, oem, "app"); public:
} LogMgr()
{
g_hLog = EnableLog(nullptr, oem, "app");
}
void global_unload(void) ~LogMgr()
{ {
DisableLog(g_hLog); DisableLog(g_hLog);
g_hLog = nullptr; g_hLog = nullptr;
} }
};
LogMgr g_logMgr;
#endif #endif