rayzor

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/logger.c	Sat Apr 05 08:46:27 2014 +0300
     1.3 @@ -0,0 +1,23 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdarg.h>
     1.6 +#include "logger.h"
     1.7 +
     1.8 +#define LOGFNAME	"rayzor.log"
     1.9 +
    1.10 +static FILE *logfile;
    1.11 +
    1.12 +void printlog(const char *fmt, ...)
    1.13 +{
    1.14 +	va_list ap;
    1.15 +
    1.16 +	if(!logfile) {
    1.17 +		if(!(logfile = fopen(LOGFNAME, "w"))) {
    1.18 +			return;
    1.19 +		}
    1.20 +		setvbuf(logfile, 0, _IOLBF, 0);
    1.21 +	}
    1.22 +
    1.23 +	va_start(ap, fmt);
    1.24 +	vfprintf(logfile, fmt, ap);
    1.25 +	va_end(ap);
    1.26 +}