2013-09-15 23:46:02 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/tchar.h>
|
|
|
|
#include <winpr/wlog.h>
|
|
|
|
|
|
|
|
int TestWLog(int argc, char* argv[])
|
|
|
|
{
|
2013-09-16 00:48:09 +04:00
|
|
|
wLog* log;
|
2013-09-17 00:30:49 +04:00
|
|
|
wLogLayout* layout;
|
2013-09-16 20:56:22 +04:00
|
|
|
wLogAppender* appender;
|
2013-09-16 00:48:09 +04:00
|
|
|
|
2013-10-02 00:08:26 +04:00
|
|
|
log = WLog_New("com.log.test.console");
|
2013-09-16 00:48:09 +04:00
|
|
|
|
|
|
|
WLog_SetLogLevel(log, WLOG_INFO);
|
2013-09-16 20:05:08 +04:00
|
|
|
|
|
|
|
WLog_SetLogAppenderType(log, WLOG_APPENDER_CONSOLE);
|
2013-09-16 20:56:22 +04:00
|
|
|
appender = WLog_GetLogAppender(log);
|
2013-09-16 20:05:08 +04:00
|
|
|
|
2013-09-17 00:30:49 +04:00
|
|
|
layout = WLog_GetLogLayout(log);
|
|
|
|
WLog_Layout_SetPrefixFormat(log, layout, "[%lv:%mn] [%fl|%fn|%ln] - ");
|
|
|
|
|
2013-09-16 20:56:22 +04:00
|
|
|
WLog_ConsoleAppender_SetOutputStream(log, (wLogConsoleAppender*) appender, WLOG_CONSOLE_STDERR);
|
|
|
|
WLog_OpenAppender(log);
|
2013-09-16 20:05:08 +04:00
|
|
|
|
2013-09-16 00:48:09 +04:00
|
|
|
WLog_Print(log, WLOG_INFO, "this is a test");
|
|
|
|
WLog_Print(log, WLOG_WARN, "this is a %dnd %s", 2, "test");
|
|
|
|
WLog_Print(log, WLOG_ERROR, "this is an error");
|
|
|
|
WLog_Print(log, WLOG_TRACE, "this is a trace output");
|
|
|
|
|
2013-09-16 20:56:22 +04:00
|
|
|
WLog_CloseAppender(log);
|
|
|
|
WLog_Free(log);
|
|
|
|
|
2013-10-02 00:08:26 +04:00
|
|
|
log = WLog_New("com.log.test.file");
|
2013-09-16 20:56:22 +04:00
|
|
|
|
|
|
|
WLog_SetLogLevel(log, WLOG_WARN);
|
|
|
|
|
|
|
|
WLog_SetLogAppenderType(log, WLOG_APPENDER_FILE);
|
|
|
|
appender = WLog_GetLogAppender(log);
|
|
|
|
|
2013-09-17 00:30:49 +04:00
|
|
|
layout = WLog_GetLogLayout(log);
|
|
|
|
WLog_Layout_SetPrefixFormat(log, layout, "[%lv:%mn] [%fl|%fn|%ln] - ");
|
|
|
|
|
2013-09-16 20:56:22 +04:00
|
|
|
WLog_FileAppender_SetOutputFileName(log, (wLogFileAppender*) appender, "/tmp/wlog_test.log");
|
|
|
|
WLog_OpenAppender(log);
|
|
|
|
|
|
|
|
WLog_Print(log, WLOG_INFO, "this is a test");
|
|
|
|
WLog_Print(log, WLOG_WARN, "this is a %dnd %s", 2, "test");
|
|
|
|
WLog_Print(log, WLOG_ERROR, "this is an error");
|
|
|
|
WLog_Print(log, WLOG_TRACE, "this is a trace output");
|
|
|
|
|
|
|
|
WLog_CloseAppender(log);
|
2013-09-16 00:48:09 +04:00
|
|
|
WLog_Free(log);
|
2013-09-15 23:46:02 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|