base.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /******************************************************************************
  2. Copyright (c) 2013 by Hugh Bailey <[email protected]>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely, subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not
  10. claim that you wrote the original software. If you use this software
  11. in a product, an acknowledgment in the product documentation would be
  12. appreciated but is not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source
  16. distribution.
  17. ******************************************************************************/
  18. #pragma once
  19. #include <wctype.h>
  20. #include <stdarg.h>
  21. #include "c99defs.h"
  22. /*
  23. * Just contains logging/crash related stuff
  24. */
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. enum log_type {
  29. LOG_DEBUG,
  30. LOG_INFO,
  31. LOG_WARNING,
  32. LOG_ERROR
  33. };
  34. EXPORT void base_set_log_handler(
  35. void (*handler)(enum log_type, const char *, va_list));
  36. EXPORT void base_set_crash_handler(void (*handler)(const char *, va_list));
  37. #ifndef _MSC_VER
  38. #define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
  39. #else
  40. #define PRINTFATTR(f, a)
  41. #endif
  42. PRINTFATTR(2, 3)
  43. EXPORT void blog(enum log_type type, const char *format, ...);
  44. PRINTFATTR(1, 2)
  45. EXPORT void bcrash(const char *format, ...);
  46. #undef PRINTFATTR
  47. #ifdef __cplusplus
  48. }
  49. #endif