32 #include <winpr/wtypes.h>
33 #include <winpr/winpr.h>
34 #include <winpr/synch.h>
35 #include <winpr/thread.h>
47 #define WLOG_LEVEL_INHERIT 0xFFFF
52 #define WLOG_MESSAGE_TEXT 0
53 #define WLOG_MESSAGE_DATA 1
54 #define WLOG_MESSAGE_IMAGE 2
55 #define WLOG_MESSAGE_PACKET 3
60 #define WLOG_APPENDER_CONSOLE 0
61 #define WLOG_APPENDER_FILE 1
62 #define WLOG_APPENDER_BINARY 2
63 #define WLOG_APPENDER_CALLBACK 3
64 #define WLOG_APPENDER_SYSLOG 4
65 #define WLOG_APPENDER_JOURNALD 5
66 #define WLOG_APPENDER_UDP 6
103 typedef struct s_wLog wLog;
105 #define WLOG_PACKET_INBOUND 1
106 #define WLOG_PACKET_OUTBOUND 2
108 WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level,
size_t line,
109 const char* file,
const char*
function, ...);
110 WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level,
size_t line,
111 const char* file,
const char*
function, va_list args);
113 WINPR_API wLog* WLog_GetRoot(
void);
114 WINPR_API wLog* WLog_Get(LPCSTR name);
115 WINPR_API DWORD WLog_GetLogLevel(wLog* log);
116 WINPR_API BOOL WLog_IsLevelActive(wLog* _log, DWORD _log_level);
128 WINPR_API BOOL WLog_SetContext(wLog* log,
const char* (*fkt)(
void*),
void* context);
130 #define WLog_Print_unchecked(_log, _log_level, ...) \
133 WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, __func__, \
137 #define WLog_Print(_log, _log_level, ...) \
140 if (WLog_IsLevelActive(_log, _log_level)) \
142 WLog_Print_unchecked(_log, _log_level, __VA_ARGS__); \
146 #define WLog_Print_tag(_tag, _log_level, ...) \
149 static wLog* _log_cached_ptr = NULL; \
150 if (!_log_cached_ptr) \
151 _log_cached_ptr = WLog_Get(_tag); \
152 WLog_Print(_log_cached_ptr, _log_level, __VA_ARGS__); \
155 #define WLog_PrintVA_unchecked(_log, _log_level, _args) \
158 WLog_PrintMessageVA(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, __func__, \
162 #define WLog_PrintVA(_log, _log_level, _args) \
165 if (WLog_IsLevelActive(_log, _log_level)) \
167 WLog_PrintVA_unchecked(_log, _log_level, _args); \
171 #define WLog_Data(_log, _log_level, ...) \
174 if (WLog_IsLevelActive(_log, _log_level)) \
176 WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, __func__, \
181 #define WLog_Image(_log, _log_level, ...) \
184 if (WLog_IsLevelActive(_log, _log_level)) \
186 WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, __func__, \
191 #define WLog_Packet(_log, _log_level, ...) \
194 if (WLog_IsLevelActive(_log, _log_level)) \
196 WLog_PrintMessage(_log, WLOG_MESSAGE_PACKET, _log_level, __LINE__, __FILE__, __func__, \
201 #define WLog_LVL(tag, lvl, ...) WLog_Print_tag(tag, lvl, __VA_ARGS__)
202 #define WLog_VRB(tag, ...) WLog_Print_tag(tag, WLOG_TRACE, __VA_ARGS__)
203 #define WLog_DBG(tag, ...) WLog_Print_tag(tag, WLOG_DEBUG, __VA_ARGS__)
204 #define WLog_INFO(tag, ...) WLog_Print_tag(tag, WLOG_INFO, __VA_ARGS__)
205 #define WLog_WARN(tag, ...) WLog_Print_tag(tag, WLOG_WARN, __VA_ARGS__)
206 #define WLog_ERR(tag, ...) WLog_Print_tag(tag, WLOG_ERROR, __VA_ARGS__)
207 #define WLog_FATAL(tag, ...) WLog_Print_tag(tag, WLOG_FATAL, __VA_ARGS__)
209 WINPR_API BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel);
210 WINPR_API BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level);
211 WINPR_API BOOL WLog_AddStringLogFilters(LPCSTR filter);
213 WINPR_API BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType);
214 WINPR_API wLogAppender* WLog_GetLogAppender(wLog* log);
215 WINPR_API BOOL WLog_OpenAppender(wLog* log);
216 WINPR_API BOOL WLog_CloseAppender(wLog* log);
217 WINPR_API BOOL WLog_ConfigureAppender(wLogAppender* appender,
const char* setting,
void* value);
219 WINPR_API wLogLayout* WLog_GetLogLayout(wLog* log);
220 WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout,
const char* format);
222 #if defined(WITH_WINPR_DEPRECATED)
224 WINPR_API WINPR_DEPRECATED(BOOL WLog_Init(
void));
226 WINPR_API WINPR_DEPRECATED(BOOL WLog_Uninit(
void));
229 typedef BOOL (*wLogCallbackMessage_t)(
const wLogMessage* msg);
230 typedef BOOL (*wLogCallbackData_t)(
const wLogMessage* msg);
231 typedef BOOL (*wLogCallbackImage_t)(
const wLogMessage* msg);
232 typedef BOOL (*wLogCallbackPackage_t)(
const wLogMessage* msg);
236 wLogCallbackData_t data;
237 wLogCallbackImage_t image;
238 wLogCallbackMessage_t message;
239 wLogCallbackPackage_t package;