mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[host] windows: move the service log to the temp directory
Often this log is provided instead of the actual host log, as this log is largely useless for debugging this moves it to the temp directory out of view of the user.
This commit is contained in:
parent
9123984ecc
commit
6a72633674
@ -58,6 +58,7 @@ struct AppState
|
||||
|
||||
char executable[MAX_PATH + 1];
|
||||
char systemLogDir[MAX_PATH];
|
||||
char systemTempDir[MAX_PATH];
|
||||
char * osVersion;
|
||||
HWND messageWnd;
|
||||
UINT shellHookMsg;
|
||||
@ -299,6 +300,11 @@ static BOOL WINAPI CtrlHandler(DWORD dwCtrlType)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char * getSystemTempDirectory(void)
|
||||
{
|
||||
return app.systemTempDir;
|
||||
}
|
||||
|
||||
const char *getSystemLogDirectory(void)
|
||||
{
|
||||
return app.systemLogDir;
|
||||
@ -340,6 +346,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
GetModuleFileName(NULL, app.executable, sizeof(app.executable));
|
||||
populateSystemLogDirectory();
|
||||
GetTempPathA(sizeof(app.systemTempDir), app.systemTempDir);
|
||||
|
||||
if (HandleService(app.argc, app.argv))
|
||||
return LG_HOST_EXIT_FAILED;
|
||||
|
@ -51,5 +51,6 @@ struct MSG_CALL_FUNCTION
|
||||
};
|
||||
|
||||
bool windowsSetupAPI(void);
|
||||
const char *getSystemLogDirectory(void);
|
||||
const char * getSystemTempDirectory(void);
|
||||
const char * getSystemLogDirectory(void);
|
||||
LRESULT sendAppMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
@ -78,7 +78,13 @@ void doLogReal(const char * fmt, ...)
|
||||
static void setupLogging(void)
|
||||
{
|
||||
char logFilePath[MAX_PATH];
|
||||
if (!PathCombineA(logFilePath, getSystemLogDirectory(), LOG_NAME))
|
||||
|
||||
// remove the old service log file if it exists
|
||||
if (PathCombineA(logFilePath, getSystemLogDirectory(), LOG_NAME))
|
||||
unlink(logFilePath);
|
||||
|
||||
// open the service file in the temp directory as we usually do not need it
|
||||
if (!PathCombineA(logFilePath, getSystemTempDirectory(), LOG_NAME))
|
||||
strcpy(logFilePath, LOG_NAME);
|
||||
service.logFile = fopen(logFilePath, "a+");
|
||||
setbuf(service.logFile, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user