amiga_imgv
annotate src/logger.c @ 7:4c36d0f44aa6
lbm loading
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 29 Oct 2017 13:21:11 +0200 |
parents | a4788c959918 |
children |
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@6 | 10 #ifdef __unix__ |
nuclear@6 | 11 fp = stdout; |
nuclear@6 | 12 #else |
nuclear@0 | 13 if(!(fp = fopen("logfile", "w"))) { |
nuclear@0 | 14 printf("failed to open logfile\n"); |
nuclear@0 | 15 abort(); |
nuclear@0 | 16 } |
nuclear@0 | 17 setvbuf(fp, 0, _IONBF, 0); |
nuclear@6 | 18 #endif |
nuclear@0 | 19 } |
nuclear@0 | 20 |
nuclear@0 | 21 void logmsg(const char *fmt, ...) |
nuclear@0 | 22 { |
nuclear@0 | 23 va_list ap; |
nuclear@0 | 24 |
nuclear@0 | 25 if(!fp) init(); |
nuclear@0 | 26 |
nuclear@0 | 27 va_start(ap, fmt); |
nuclear@0 | 28 vfprintf(fp, fmt, ap); |
nuclear@0 | 29 va_end(ap); |
nuclear@0 | 30 } |