sgl
annotate src/log.c @ 18:33acb6b2d7a4
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 25 Jun 2011 05:24:49 +0300 |
parents | 648f8604d2b2 |
children | 124195562f7e |
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@5 | 20 if(fp != stderr) { |
nuclear@5 | 21 fclose(fp); |
nuclear@5 | 22 } |
nuclear@4 | 23 } |