diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-25 10:05:49 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-25 10:05:49 +0100 |
commit | d5a0d432b679f0c4a8cc0a74d766ba03a008f7d9 (patch) | |
tree | 8d808f7579020e1db8f276ad747cdd31657f3f33 /include | |
parent | 9a797e37f07ca227eb2153437fa7d894cab4c244 (diff) | |
download | wolfbones-d5a0d432b679f0c4a8cc0a74d766ba03a008f7d9.tar.gz wolfbones-d5a0d432b679f0c4a8cc0a74d766ba03a008f7d9.tar.bz2 |
fixed logger again, on Unix we stick to strerror_r+wolf_log (simple enough and doesn't introduce dependencies on variadic macros or similar stuff)
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 |