rayzor
annotate src/logger.c @ 14:a9a948809c6f
starting the renderer screen, plus misc stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 13 Apr 2014 08:06:21 +0300 |
parents | a826bf0fb169 |
children |
rev | line source |
---|---|
nuclear@1 | 1 #include <stdio.h> |
nuclear@1 | 2 #include <stdarg.h> |
nuclear@1 | 3 #include "logger.h" |
nuclear@1 | 4 |
nuclear@1 | 5 #define LOGFNAME "rayzor.log" |
nuclear@1 | 6 |
nuclear@1 | 7 static FILE *logfile; |
nuclear@1 | 8 |
nuclear@6 | 9 void logger_output(FILE *fp) |
nuclear@6 | 10 { |
nuclear@6 | 11 if(logfile) fclose(logfile); |
nuclear@6 | 12 logfile = fp; |
nuclear@6 | 13 } |
nuclear@6 | 14 |
nuclear@1 | 15 void printlog(const char *fmt, ...) |
nuclear@1 | 16 { |
nuclear@1 | 17 va_list ap; |
nuclear@1 | 18 |
nuclear@1 | 19 if(!logfile) { |
nuclear@1 | 20 if(!(logfile = fopen(LOGFNAME, "w"))) { |
nuclear@1 | 21 return; |
nuclear@1 | 22 } |
nuclear@1 | 23 setvbuf(logfile, 0, _IOLBF, 0); |
nuclear@1 | 24 } |
nuclear@1 | 25 |
nuclear@1 | 26 va_start(ap, fmt); |
nuclear@1 | 27 vfprintf(logfile, fmt, ap); |
nuclear@1 | 28 va_end(ap); |
nuclear@1 | 29 } |