Replace printf/fprintf with own print_info() / print_error() using SDL_log
[mercenary-reloaded.git] / src / libsdl / print.c
1
2 #include <stdio.h>
3 #include <stdarg.h>
4 #include <SDL2/SDL_log.h>
5
6 void __attribute__ ((format (printf, 1, 2))) _print_info(const char *format, ...)
7 {
8         va_list args;
9         va_start(args, format);
10
11         SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, format, args);
12
13         va_end(args);
14 }
15
16 void __attribute__ ((format (printf, 3, 4))) _print_error(const char *_file, int _line, const char *format, ...)
17 {
18         va_list args;
19         va_start(args, format);
20
21         SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Error in %s line %d:\n", _file, _line);
22         SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, format, args);
23
24         va_end(args);
25 }
26