libwinpr-utils: extend wlog prefix format

This commit is contained in:
Marc-André Moreau 2014-05-28 10:38:32 -04:00
parent ba5d84ee5c
commit af6fb83d3b
4 changed files with 106 additions and 7 deletions

View File

@ -214,6 +214,11 @@ WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation);
#define GetVersionEx GetVersionExA
#endif
WINPR_API void GetSystemTime(LPSYSTEMTIME lpSystemTime);
WINPR_API BOOL SetSystemTime(CONST SYSTEMTIME* lpSystemTime);
WINPR_API VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
WINPR_API BOOL SetLocalTime(CONST SYSTEMTIME* lpSystemTime);
WINPR_API VOID GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime);
WINPR_API DWORD GetTickCount(void);

View File

@ -121,7 +121,7 @@ PSCardApiFunctionTable WinSCard_GetSCardApiFunctionTable(void)
int WinSCard_InitializeSCardApi(void)
{
g_WinSCardModule = LoadLibraryA("winscard.dll");
g_WinSCardModule = LoadLibraryA("WinSCard.dll");
if (!g_WinSCardModule)
return -1;

View File

@ -296,6 +296,11 @@ BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation)
return 1;
}
void GetSystemTime(LPSYSTEMTIME lpSystemTime)
{
}
VOID GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
{
ULARGE_INTEGER time64;
@ -311,6 +316,21 @@ VOID GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
lpSystemTimeAsFileTime->dwHighDateTime = time64.HighPart;
}
BOOL SetSystemTime(CONST SYSTEMTIME* lpSystemTime)
{
return FALSE;
}
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
{
}
BOOL SetLocalTime(CONST SYSTEMTIME* lpSystemTime)
{
return FALSE;
}
#ifndef CLOCK_MONOTONIC_RAW
#define CLOCK_MONOTONIC_RAW 4
#endif
@ -606,6 +626,7 @@ BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature)
#endif
return ret;
}
#endif //_WIN32
BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature)

View File

@ -64,7 +64,10 @@ void WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
int index;
int argc = 0;
void* args[32];
char format[128];
char format[256];
SYSTEMTIME localTime;
GetLocalTime(&localTime);
index = 0;
p = (char*) layout->FormatString;
@ -77,21 +80,21 @@ void WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
if (*p)
{
if ((*p == 'l') && (*(p + 1) == 'v')) /* log level */
if ((p[0] == 'l') && (p[1] == 'v')) /* log level */
{
args[argc++] = (void*) WLOG_LEVELS[message->Level];
format[index++] = '%';
format[index++] = 's';
p++;
}
else if ((*p == 'm') && (*(p + 1) == 'n')) /* module name */
else if ((p[0] == 'm') && (p[1] == 'n')) /* module name */
{
args[argc++] = (void*) log->Name;
format[index++] = '%';
format[index++] = 's';
p++;
}
else if ((*p == 'f') && (*(p + 1) == 'l')) /* file */
else if ((p[0] == 'f') && (p[1] == 'l')) /* file */
{
char* file;
@ -110,20 +113,90 @@ void WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
format[index++] = 's';
p++;
}
else if ((*p == 'f') && (*(p + 1) == 'n')) /* function */
else if ((p[0] == 'f') && (p[1] == 'n')) /* function */
{
args[argc++] = (void*) message->FunctionName;
format[index++] = '%';
format[index++] = 's';
p++;
}
else if ((*p == 'l') && (*(p + 1) == 'n')) /* line number */
else if ((p[0] == 'l') && (p[1] == 'n')) /* line number */
{
args[argc++] = (void*) (size_t) message->LineNumber;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'p') && (p[1] == 'i') && (p[2] == 'd')) /* process id */
{
args[argc++] = (void*) (size_t) GetCurrentProcessId();
format[index++] = '%';
format[index++] = 'd';
p += 2;
}
else if ((p[0] == 't') && (p[1] == 'i') && (p[2] == 'd')) /* thread id */
{
args[argc++] = (void*) (size_t) GetCurrentThreadId();
format[index++] = '%';
format[index++] = 'd';
p += 2;
}
else if ((p[0] == 'y') && (p[1] == 'r')) /* year */
{
args[argc++] = (void*) (size_t) localTime.wYear;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'm') && (p[1] == 'o')) /* month */
{
args[argc++] = (void*) (size_t) localTime.wMonth;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'd') && (p[1] == 'w')) /* day of week */
{
args[argc++] = (void*) (size_t) localTime.wDayOfWeek;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'd') && (p[1] == 'y')) /* day */
{
args[argc++] = (void*) (size_t) localTime.wDay;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'h') && (p[1] == 'r')) /* hours */
{
args[argc++] = (void*) (size_t) localTime.wHour;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'm') && (p[1] == 'i')) /* minutes */
{
args[argc++] = (void*) (size_t) localTime.wMinute;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 's') && (p[1] == 'e')) /* seconds */
{
args[argc++] = (void*) (size_t) localTime.wSecond;
format[index++] = '%';
format[index++] = 'd';
p++;
}
else if ((p[0] == 'm') && (p[1] == 'l')) /* milliseconds */
{
args[argc++] = (void*) (size_t) localTime.wMilliseconds;
format[index++] = '%';
format[index++] = 'd';
p++;
}
}
}
else