sgl
annotate 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 |
rev | line source |
---|---|
nuclear@4 | 1 #include <stdio.h> |
nuclear@4 | 2 #include <stdlib.h> |
nuclear@4 | 3 #include <stdarg.h> |
nuclear@4 | 4 #include "log.h" |
nuclear@4 | 5 |
nuclear@4 | 6 void sgl_log(const char *fmt, ...) |
nuclear@4 | 7 { |
nuclear@4 | 8 va_list ap; |
nuclear@4 | 9 const char *logfile; |
nuclear@4 | 10 FILE *fp; |
nuclear@4 | 11 |
nuclear@4 | 12 if(!(logfile = getenv("SGL_LOG")) || !(fp = fopen(logfile, "a"))) { |
nuclear@4 | 13 fp = stderr; |
nuclear@4 | 14 } |
nuclear@4 | 15 |
nuclear@4 | 16 va_start(ap, fmt); |
nuclear@4 | 17 vfprintf(fp, fmt, ap); |
nuclear@4 | 18 va_end(ap); |
nuclear@4 | 19 |
nuclear@4 | 20 fclose(fp); |
nuclear@4 | 21 } |