amiga_imgv
view src/logger.c @ 6:ae0ada629b03
wohooo it works :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 Oct 2017 15:42:58 +0300 |
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 }