rayzor
view src/logger.c @ 9:70e332156d02
moving along
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 10 Apr 2014 02:31:31 +0300 |
parents | a826bf0fb169 |
children |
line source
1 #include <stdio.h>
2 #include <stdarg.h>
3 #include "logger.h"
5 #define LOGFNAME "rayzor.log"
7 static FILE *logfile;
9 void logger_output(FILE *fp)
10 {
11 if(logfile) fclose(logfile);
12 logfile = fp;
13 }
15 void printlog(const char *fmt, ...)
16 {
17 va_list ap;
19 if(!logfile) {
20 if(!(logfile = fopen(LOGFNAME, "w"))) {
21 return;
22 }
23 setvbuf(logfile, 0, _IOLBF, 0);
24 }
26 va_start(ap, fmt);
27 vfprintf(logfile, fmt, ap);
28 va_end(ap);
29 }