amiga_imgv

annotate 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
rev   line source
nuclear@0 1 #include <stdio.h>
nuclear@0 2 #include <stdlib.h>
nuclear@0 3 #include <stdarg.h>
nuclear@0 4 #include "logger.h"
nuclear@0 5
nuclear@0 6 static FILE *fp;
nuclear@0 7
nuclear@0 8 static void init(void)
nuclear@0 9 {
nuclear@0 10 if(!(fp = fopen("logfile", "w"))) {
nuclear@0 11 printf("failed to open logfile\n");
nuclear@0 12 abort();
nuclear@0 13 }
nuclear@0 14 setvbuf(fp, 0, _IONBF, 0);
nuclear@0 15 }
nuclear@0 16
nuclear@0 17 void logmsg(const char *fmt, ...)
nuclear@0 18 {
nuclear@0 19 va_list ap;
nuclear@0 20
nuclear@0 21 if(!fp) init();
nuclear@0 22
nuclear@0 23 va_start(ap, fmt);
nuclear@0 24 vfprintf(fp, fmt, ap);
nuclear@0 25 va_end(ap);
nuclear@0 26 }