|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* WinPR: Windows Portable Runtime
|
|
Packit Service |
fa4841 |
* WinPR Logger
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
Packit Service |
fa4841 |
* Copyright 2015 Thincast Technologies GmbH
|
|
Packit Service |
fa4841 |
* Copyright 2015 Bernhard Miklautz <bernhard.miklautz@thincast.com>
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
fa4841 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
fa4841 |
* You may obtain a copy of the License at
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
fa4841 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
fa4841 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
fa4841 |
* See the License for the specific language governing permissions and
|
|
Packit Service |
fa4841 |
* limitations under the License.
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifndef WINPR_LOG_H
|
|
Packit Service |
fa4841 |
#define WINPR_LOG_H
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef __cplusplus
|
|
Packit Service |
b1ea74 |
extern "C"
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#include <stdarg.h>
|
|
Packit Service |
fa4841 |
#include <winpr/wtypes.h>
|
|
Packit Service |
fa4841 |
#include <winpr/synch.h>
|
|
Packit Service |
fa4841 |
#include <winpr/thread.h>
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* Log Levels
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
b1ea74 |
#define WLOG_TRACE 0
|
|
Packit Service |
b1ea74 |
#define WLOG_DEBUG 1
|
|
Packit Service |
b1ea74 |
#define WLOG_INFO 2
|
|
Packit Service |
b1ea74 |
#define WLOG_WARN 3
|
|
Packit Service |
b1ea74 |
#define WLOG_ERROR 4
|
|
Packit Service |
b1ea74 |
#define WLOG_FATAL 5
|
|
Packit Service |
b1ea74 |
#define WLOG_OFF 6
|
|
Packit Service |
fa4841 |
#define WLOG_LEVEL_INHERIT 0xFFFF
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* Log Message
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
b1ea74 |
#define WLOG_MESSAGE_TEXT 0
|
|
Packit Service |
b1ea74 |
#define WLOG_MESSAGE_DATA 1
|
|
Packit Service |
b1ea74 |
#define WLOG_MESSAGE_IMAGE 2
|
|
Packit Service |
b1ea74 |
#define WLOG_MESSAGE_PACKET 3
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* Log Appenders
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_CONSOLE 0
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_FILE 1
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_BINARY 2
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_CALLBACK 3
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_SYSLOG 4
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_JOURNALD 5
|
|
Packit Service |
b1ea74 |
#define WLOG_APPENDER_UDP 6
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
struct _wLogMessage
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
b1ea74 |
DWORD Type;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
DWORD Level;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
LPSTR PrefixString;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
LPCSTR FormatString;
|
|
Packit Service |
b1ea74 |
LPSTR TextString;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
DWORD LineNumber; /* __LINE__ */
|
|
Packit Service |
b1ea74 |
LPCSTR FileName; /* __FILE__ */
|
|
Packit Service |
b1ea74 |
LPCSTR FunctionName; /* __FUNCTION__ */
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
/* Data Message */
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
void* Data;
|
|
Packit Service |
b1ea74 |
int Length;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
/* Image Message */
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
void* ImageData;
|
|
Packit Service |
b1ea74 |
int ImageWidth;
|
|
Packit Service |
b1ea74 |
int ImageHeight;
|
|
Packit Service |
b1ea74 |
int ImageBpp;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
/* Packet Message */
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
void* PacketData;
|
|
Packit Service |
b1ea74 |
int PacketLength;
|
|
Packit Service |
b1ea74 |
DWORD PacketFlags;
|
|
Packit Service |
b1ea74 |
};
|
|
Packit Service |
b1ea74 |
typedef struct _wLogMessage wLogMessage;
|
|
Packit Service |
b1ea74 |
typedef struct _wLogLayout wLogLayout;
|
|
Packit Service |
b1ea74 |
typedef struct _wLogAppender wLogAppender;
|
|
Packit Service |
b1ea74 |
typedef struct _wLog wLog;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
#define WLOG_PACKET_INBOUND 1
|
|
Packit Service |
b1ea74 |
#define WLOG_PACKET_OUTBOUND 2
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, DWORD line,
|
|
Packit Service |
b1ea74 |
const char* file, const char* function, ...);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line,
|
|
Packit Service |
b1ea74 |
const char* file, const char* function, va_list args);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API wLog* WLog_GetRoot(void);
|
|
Packit Service |
b1ea74 |
WINPR_API wLog* WLog_Get(LPCSTR name);
|
|
Packit Service |
b1ea74 |
WINPR_API DWORD WLog_GetLogLevel(wLog* log);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_IsLevelActive(wLog* _log, DWORD _log_level);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
#define WLog_Print(_log, _log_level, ...) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
if (WLog_IsLevelActive(_log, _log_level)) \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, \
|
|
Packit Service |
b1ea74 |
__FUNCTION__, __VA_ARGS__); \
|
|
Packit Service |
b1ea74 |
} \
|
|
Packit Service |
fa4841 |
} while (0)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define WLog_Print_tag(_tag, _log_level, ...) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
static wLog* _log_cached_ptr = NULL; \
|
|
Packit Service |
b1ea74 |
if (!_log_cached_ptr) \
|
|
Packit Service |
b1ea74 |
_log_cached_ptr = WLog_Get(_tag); \
|
|
Packit Service |
b1ea74 |
WLog_Print(_log_cached_ptr, _log_level, __VA_ARGS__); \
|
|
Packit Service |
fa4841 |
} while (0)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define WLog_PrintVA(_log, _log_level, _args) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
if (WLog_IsLevelActive(_log, _log_level)) \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
WLog_PrintMessageVA(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, \
|
|
Packit Service |
b1ea74 |
__FUNCTION__, _args); \
|
|
Packit Service |
b1ea74 |
} \
|
|
Packit Service |
fa4841 |
} while (0)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define WLog_Data(_log, _log_level, ...) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
if (WLog_IsLevelActive(_log, _log_level)) \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, \
|
|
Packit Service |
b1ea74 |
__FUNCTION__, __VA_ARGS__); \
|
|
Packit Service |
b1ea74 |
} \
|
|
Packit Service |
fa4841 |
} while (0)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define WLog_Image(_log, _log_level, ...) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
if (WLog_IsLevelActive(_log, _log_level)) \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, \
|
|
Packit Service |
b1ea74 |
__FUNCTION__, __VA_ARGS__); \
|
|
Packit Service |
b1ea74 |
} \
|
|
Packit Service |
fa4841 |
} while (0)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define WLog_Packet(_log, _log_level, ...) \
|
|
Packit Service |
b1ea74 |
do \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
if (WLog_IsLevelActive(_log, _log_level)) \
|
|
Packit Service |
b1ea74 |
{ \
|
|
Packit Service |
b1ea74 |
WLog_PrintMessage(_log, WLOG_MESSAGE_PACKET, _log_level, __LINE__, __FILE__, \
|
|
Packit Service |
b1ea74 |
__FUNCTION__, __VA_ARGS__); \
|
|
Packit Service |
b1ea74 |
} \
|
|
Packit Service |
b1ea74 |
} while (0)
|
|
Packit Service |
bb5c11 |
|
|
Packit Service |
b1ea74 |
#define WLog_LVL(tag, lvl, ...) WLog_Print_tag(tag, lvl, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_VRB(tag, ...) WLog_Print_tag(tag, WLOG_TRACE, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_DBG(tag, ...) WLog_Print_tag(tag, WLOG_DEBUG, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_INFO(tag, ...) WLog_Print_tag(tag, WLOG_INFO, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_WARN(tag, ...) WLog_Print_tag(tag, WLOG_WARN, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_ERR(tag, ...) WLog_Print_tag(tag, WLOG_ERROR, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
#define WLog_FATAL(tag, ...) WLog_Print_tag(tag, WLOG_FATAL, __VA_ARGS__)
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_AddStringLogFilters(LPCSTR filter);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType);
|
|
Packit Service |
b1ea74 |
WINPR_API wLogAppender* WLog_GetLogAppender(wLog* log);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_OpenAppender(wLog* log);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_CloseAppender(wLog* log);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_ConfigureAppender(wLogAppender* appender, const char* setting, void* value);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API wLogLayout* WLog_GetLogLayout(wLog* log);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* format);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
/** Deprecated */
|
|
Packit Service |
b1ea74 |
WINPR_API WINPR_DEPRECATED(BOOL WLog_Init(void));
|
|
Packit Service |
b1ea74 |
/** Deprecated */
|
|
Packit Service |
b1ea74 |
WINPR_API WINPR_DEPRECATED(BOOL WLog_Uninit(void));
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
typedef BOOL (*wLogCallbackMessage_t)(const wLogMessage* msg);
|
|
Packit Service |
b1ea74 |
typedef BOOL (*wLogCallbackData_t)(const wLogMessage* msg);
|
|
Packit Service |
b1ea74 |
typedef BOOL (*wLogCallbackImage_t)(const wLogMessage* msg);
|
|
Packit Service |
b1ea74 |
typedef BOOL (*wLogCallbackPackage_t)(const wLogMessage* msg);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
struct _wLogCallbacks
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
b1ea74 |
wLogCallbackData_t data;
|
|
Packit Service |
b1ea74 |
wLogCallbackImage_t image;
|
|
Packit Service |
b1ea74 |
wLogCallbackMessage_t message;
|
|
Packit Service |
b1ea74 |
wLogCallbackPackage_t package;
|
|
Packit Service |
b1ea74 |
};
|
|
Packit Service |
b1ea74 |
typedef struct _wLogCallbacks wLogCallbacks;
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef __cplusplus
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif /* WINPR_WLOG_H */
|