sgl

diff src/log.c @ 4:648f8604d2b2

cont. x11 module
author John Tsiombikas <nuclear@siggraph.org>
date Thu, 12 May 2011 11:04:10 +0300
parents
children 0570e27e5ebc
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/log.c	Thu May 12 11:04:10 2011 +0300
     1.3 @@ -0,0 +1,21 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#include <stdarg.h>
     1.7 +#include "log.h"
     1.8 +
     1.9 +void sgl_log(const char *fmt, ...)
    1.10 +{
    1.11 +	va_list ap;
    1.12 +	const char *logfile;
    1.13 +	FILE *fp;
    1.14 +
    1.15 +	if(!(logfile = getenv("SGL_LOG")) || !(fp = fopen(logfile, "a"))) {
    1.16 +		fp = stderr;
    1.17 +	}
    1.18 +
    1.19 +	va_start(ap, fmt);
    1.20 +	vfprintf(fp, fmt, ap);
    1.21 +	va_end(ap);
    1.22 +
    1.23 +	fclose(fp);
    1.24 +}