goat3d

annotate exporters/maxgoat/src/logger.cc @ 61:fdece14403ff

max gui
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 31 Mar 2014 09:41:47 +0300
parents
children 9862541fdcf5
rev   line source
nuclear@61 1 #include <stdio.h>
nuclear@61 2 #include <stdarg.h>
nuclear@61 3 #include "logger.h"
nuclear@61 4
nuclear@61 5 static FILE *logfile;
nuclear@61 6
nuclear@61 7 bool maxlog_open(const char *fname)
nuclear@61 8 {
nuclear@61 9 if(!(logfile = fopen(fname, "wb"))) {
nuclear@61 10 return false;
nuclear@61 11 }
nuclear@61 12 setvbuf(logfile, 0, _IONBF, 0);
nuclear@61 13 return true;
nuclear@61 14 }
nuclear@61 15
nuclear@61 16 void maxlog_close()
nuclear@61 17 {
nuclear@61 18 if(logfile) {
nuclear@61 19 fclose(logfile);
nuclear@61 20 }
nuclear@61 21 }
nuclear@61 22
nuclear@61 23 void maxlog(const char *fmt, ...)
nuclear@61 24 {
nuclear@61 25 if(!logfile) return;
nuclear@61 26
nuclear@61 27 va_list ap;
nuclear@61 28 va_start(ap, fmt);
nuclear@61 29 vfprintf(logfile, fmt, ap);
nuclear@61 30 va_end(ap);
nuclear@61 31 }