diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/wolf/log/log.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/wolf/log/log.h b/include/wolf/log/log.h index b9f04b8..b31243b 100644 --- a/include/wolf/log/log.h +++ b/include/wolf/log/log.h @@ -19,6 +19,7 @@ #define WOLF_LOG_H #include "port/stdbool.h" +#include "port/gettext.h" /** * @addtogroup wolf_log Logging @@ -286,6 +287,34 @@ void wolf_log_reopenlogtoeventlog( void ); */ void wolf_log( wolf_log_level_t level, int category_id, int message_id, const char *format, ... ); +#ifdef _WIN32 +#define WOLF_LOG_GET_LAST_ERROR( errbuf, errbuf_size ) \ +{ \ + DWORD wolf_log_last_error = GetLastError( ); \ + LPVOID wolf_log_errbuf; \ + DWORD wolf_log_buf_size; \ + DWORD wolf_log_res; \ + \ + wolf_log_res = FormatMessage( \ + FORMAT_MESSAGE_ALLOCATE_BUFFER | \ + FORMAT_MESSAGE_FROM_SYSTEM | \ + FORMAT_MESSAGE_IGNORE_INSERTS | \ + FORMAT_MESSAGE_MAX_WIDTH_MASK, \ + NULL, /* message is from system */ \ + wolf_log_last_error, /* there is a message with that id */ \ + 0, /* default language preference */ \ + (LPTSTR)&wolf_log_errbuf,/* buffer allocated internally with LocalAlloc */\ + 0, /* minimum allocation size */ \ + NULL ); /* no arguments */ \ + \ + if( wolf_log_res == 0 ) { \ + strlcpy( wolf_log_errbuf, _( "No message available" ) \ + } \ + \ + strlcpy( errbuf, wolf_log_errbuf, errbuf_size ); \ +} +#endif + #ifdef __cplusplus } #endif |