Added the ability to initialize a FileAppender from environment variables (WLOG_FILEAPPENDER_OUTPUT_FILE_PATH and WLOG_FILEAPPENDER_OUTPUT_FILE_NAME).
This commit is contained in:
parent
aa6a737fbb
commit
bef63ad1ae
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/environment.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/path.h>
|
||||
#include <winpr/thread.h>
|
||||
@ -184,6 +185,9 @@ int WLog_FileAppender_WriteImageMessage(wLog* log, wLogFileAppender* appender, w
|
||||
|
||||
wLogFileAppender* WLog_FileAppender_New(wLog* log)
|
||||
{
|
||||
LPSTR env;
|
||||
LPCSTR name;
|
||||
DWORD nSize;
|
||||
wLogFileAppender* FileAppender;
|
||||
|
||||
FileAppender = (wLogFileAppender*) malloc(sizeof(wLogFileAppender));
|
||||
@ -207,7 +211,33 @@ wLogFileAppender* WLog_FileAppender_New(wLog* log)
|
||||
FileAppender->FileName = NULL;
|
||||
FileAppender->FilePath = NULL;
|
||||
FileAppender->FullFileName = NULL;
|
||||
}
|
||||
|
||||
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_PATH";
|
||||
nSize = GetEnvironmentVariableA(name, NULL, 0);
|
||||
if (nSize)
|
||||
{
|
||||
env = (LPSTR) malloc(nSize);
|
||||
if (env)
|
||||
{
|
||||
nSize = GetEnvironmentVariableA(name, env, nSize);
|
||||
WLog_FileAppender_SetOutputFilePath(log, FileAppender, env);
|
||||
free(env);
|
||||
}
|
||||
}
|
||||
|
||||
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_NAME";
|
||||
nSize = GetEnvironmentVariableA(name, NULL, 0);
|
||||
if (nSize)
|
||||
{
|
||||
env = (LPSTR) malloc(nSize);
|
||||
if (env)
|
||||
{
|
||||
nSize = GetEnvironmentVariableA(name, env, nSize);
|
||||
WLog_FileAppender_SetOutputFileName(log, FileAppender, env);
|
||||
free(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FileAppender;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user