rayzor

annotate src/logger.c @ 0:2a5340a6eee4

rayzor first commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Apr 2014 08:46:27 +0300
parents
children a826bf0fb169
rev   line source
nuclear@0 1 #include <stdio.h>
nuclear@0 2 #include <stdarg.h>
nuclear@0 3 #include "logger.h"
nuclear@0 4
nuclear@0 5 #define LOGFNAME "rayzor.log"
nuclear@0 6
nuclear@0 7 static FILE *logfile;
nuclear@0 8
nuclear@0 9 void printlog(const char *fmt, ...)
nuclear@0 10 {
nuclear@0 11 va_list ap;
nuclear@0 12
nuclear@0 13 if(!logfile) {
nuclear@0 14 if(!(logfile = fopen(LOGFNAME, "w"))) {
nuclear@0 15 return;
nuclear@0 16 }
nuclear@0 17 setvbuf(logfile, 0, _IOLBF, 0);
nuclear@0 18 }
nuclear@0 19
nuclear@0 20 va_start(ap, fmt);
nuclear@0 21 vfprintf(logfile, fmt, ap);
nuclear@0 22 va_end(ap);
nuclear@0 23 }