rayzor
view src/logger.c @ 22:5380ff64e83f
minor changes from dos, and line endings cleanup
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 02 May 2014 14:32:58 +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 }