amiga_imgv

view src/logger.c @ 9:01bd8bbc46d4

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Oct 2017 21:56:28 +0200
parents a4788c959918
children
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdarg.h>
4 #include "logger.h"
6 static FILE *fp;
8 static void init(void)
9 {
10 #ifdef __unix__
11 fp = stdout;
12 #else
13 if(!(fp = fopen("logfile", "w"))) {
14 printf("failed to open logfile\n");
15 abort();
16 }
17 setvbuf(fp, 0, _IONBF, 0);
18 #endif
19 }
21 void logmsg(const char *fmt, ...)
22 {
23 va_list ap;
25 if(!fp) init();
27 va_start(ap, fmt);
28 vfprintf(fp, fmt, ap);
29 va_end(ap);
30 }