amiga_imgv

view src/logger.c @ 0:a4788c959918

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 25 Oct 2017 19:34:53 +0300
parents
children ae0ada629b03
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 if(!(fp = fopen("logfile", "w"))) {
11 printf("failed to open logfile\n");
12 abort();
13 }
14 setvbuf(fp, 0, _IONBF, 0);
15 }
17 void logmsg(const char *fmt, ...)
18 {
19 va_list ap;
21 if(!fp) init();
23 va_start(ap, fmt);
24 vfprintf(fp, fmt, ap);
25 va_end(ap);
26 }