base.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2013 Hugh Bailey <[email protected]>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include <stdarg.h>
  18. #include "c99defs.h"
  19. /*
  20. * Just contains logging/crash related stuff
  21. */
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. enum log_type {
  26. LOG_DEBUG,
  27. LOG_INFO,
  28. LOG_WARNING,
  29. LOG_ERROR
  30. };
  31. EXPORT void base_set_log_handler(
  32. void (*handler)(enum log_type, const char *, va_list));
  33. EXPORT void base_set_crash_handler(void (*handler)(const char *, va_list));
  34. EXPORT void blogva(enum log_type type, const char *format, va_list args);
  35. #ifndef _MSC_VER
  36. #define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
  37. #else
  38. #define PRINTFATTR(f, a)
  39. #endif
  40. PRINTFATTR(2, 3)
  41. EXPORT void blog(enum log_type type, const char *format, ...);
  42. PRINTFATTR(1, 2)
  43. EXPORT void bcrash(const char *format, ...);
  44. #undef PRINTFATTR
  45. #ifdef __cplusplus
  46. }
  47. #endif