amiga_imgv
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/logger.c Wed Oct 25 19:34:53 2017 +0300 1.3 @@ -0,0 +1,26 @@ 1.4 +#include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <stdarg.h> 1.7 +#include "logger.h" 1.8 + 1.9 +static FILE *fp; 1.10 + 1.11 +static void init(void) 1.12 +{ 1.13 + if(!(fp = fopen("logfile", "w"))) { 1.14 + printf("failed to open logfile\n"); 1.15 + abort(); 1.16 + } 1.17 + setvbuf(fp, 0, _IONBF, 0); 1.18 +} 1.19 + 1.20 +void logmsg(const char *fmt, ...) 1.21 +{ 1.22 + va_list ap; 1.23 + 1.24 + if(!fp) init(); 1.25 + 1.26 + va_start(ap, fmt); 1.27 + vfprintf(fp, fmt, ap); 1.28 + va_end(ap); 1.29 +}