2 #include <winpr/tchar.h>
3 #include <winpr/path.h>
4 #include <winpr/file.h>
5 #include <winpr/wlog.h>
7 int TestWLog(
int argc,
char* argv[])
12 wLogLayout* layout = NULL;
13 wLogAppender* appender = NULL;
14 char* tmp_path = NULL;
15 char* wlog_file = NULL;
21 if (!(tmp_path = GetKnownPath(KNOWN_PATH_TEMP)))
23 (void)fprintf(stderr,
"Failed to get temporary directory!\n");
27 root = WLog_GetRoot();
29 WLog_SetLogAppenderType(root, WLOG_APPENDER_BINARY);
31 appender = WLog_GetLogAppender(root);
32 if (!WLog_ConfigureAppender(appender,
"outputfilename",
"test_w.log"))
34 if (!WLog_ConfigureAppender(appender,
"outputfilepath", tmp_path))
37 layout = WLog_GetLogLayout(root);
38 WLog_Layout_SetPrefixFormat(root, layout,
"[%lv:%mn] [%fl|%fn|%ln] - ");
40 WLog_OpenAppender(root);
42 logA = WLog_Get(
"com.test.ChannelA");
43 logB = WLog_Get(
"com.test.ChannelB");
45 WLog_SetLogLevel(logA, WLOG_INFO);
46 WLog_SetLogLevel(logB, WLOG_ERROR);
48 WLog_Print(logA, WLOG_INFO,
"this is a test");
49 WLog_Print(logA, WLOG_WARN,
"this is a %dnd %s", 2,
"test");
50 WLog_Print(logA, WLOG_ERROR,
"this is an error");
51 WLog_Print(logA, WLOG_TRACE,
"this is a trace output");
53 WLog_Print(logB, WLOG_INFO,
"just some info");
54 WLog_Print(logB, WLOG_WARN,
"we're warning a %dnd %s", 2,
"time");
55 WLog_Print(logB, WLOG_ERROR,
"we've got an error");
56 WLog_Print(logB, WLOG_TRACE,
"leaving a trace behind");
58 WLog_CloseAppender(root);
60 if ((wlog_file = GetCombinedPath(tmp_path,
"test_w.log")))
61 winpr_DeleteFile(wlog_file);