mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[core] improve logging in freerdp_set_last_error
This commit is contained in:
committed by
Martin Fleisz
parent
39b3847428
commit
e9bc54e8b7
@@ -614,7 +614,8 @@ owned by rdpRdp */
|
||||
FREERDP_API const char* freerdp_get_last_error_string(UINT32 error);
|
||||
FREERDP_API const char* freerdp_get_last_error_category(UINT32 error);
|
||||
|
||||
FREERDP_API void freerdp_set_last_error(rdpContext* context, UINT32 lastError);
|
||||
#define freerdp_set_last_error(context, lastError) \
|
||||
freerdp_set_last_error_ex((context), (lastError), __FUNCTION__, __FILE__, __LINE__)
|
||||
|
||||
#define freerdp_set_last_error_if_not(context, lastError) \
|
||||
do \
|
||||
|
||||
@@ -990,31 +990,41 @@ const char* freerdp_get_last_error_category(UINT32 code)
|
||||
return string;
|
||||
}
|
||||
|
||||
void freerdp_set_last_error(rdpContext* context, UINT32 lastError)
|
||||
{
|
||||
freerdp_set_last_error_ex(context, lastError, NULL, NULL, -1);
|
||||
}
|
||||
|
||||
void freerdp_set_last_error_ex(rdpContext* context, UINT32 lastError, const char* fkt,
|
||||
const char* file, int line)
|
||||
{
|
||||
static wLog* _log = NULL;
|
||||
if (_log)
|
||||
_log = WLog_Get(TAG);
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
if (lastError)
|
||||
WLog_ERR(TAG, "%s %s [0x%08" PRIX32 "]", fkt, freerdp_get_last_error_name(lastError),
|
||||
lastError);
|
||||
{
|
||||
if (WLog_IsLevelActive(_log, WLOG_ERROR))
|
||||
{
|
||||
WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, WLOG_ERROR, line, file, fkt,
|
||||
"%s [0x%08" PRIX32 "]", freerdp_get_last_error_name(lastError),
|
||||
lastError);
|
||||
}
|
||||
}
|
||||
|
||||
if (lastError == FREERDP_ERROR_SUCCESS)
|
||||
{
|
||||
WLog_DBG(TAG, "%s resetting error state", fkt);
|
||||
if (WLog_IsLevelActive(_log, WLOG_DEBUG))
|
||||
WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, WLOG_DEBUG, line, file, fkt,
|
||||
"resetting error state");
|
||||
}
|
||||
else if (context->LastError != FREERDP_ERROR_SUCCESS)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: TODO: Trying to set error code %s, but %s already set!", fkt,
|
||||
freerdp_get_last_error_name(lastError),
|
||||
freerdp_get_last_error_name(context->LastError));
|
||||
if (WLog_IsLevelActive(_log, WLOG_ERROR))
|
||||
{
|
||||
WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, WLOG_ERROR, line, file, fkt,
|
||||
"TODO: Trying to set error code %s, but %s already set!",
|
||||
freerdp_get_last_error_name(lastError),
|
||||
freerdp_get_last_error_name(context->LastError));
|
||||
}
|
||||
}
|
||||
|
||||
context->LastError = lastError;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user