projects
/
xdos
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
initial commit
[xdos]
/
src
/
logger.c
1
#include <stdio.h>
2
#include <stdarg.h>
3
#include "logger.h"
4
5
#define LOGFNAME "xdos.log"
6
7
static FILE *logfile;
8
9
void logger_output(FILE *fp)
10
{
11
if(logfile) fclose(logfile);
12
logfile = fp;
13
}
14
15
void printlog(const char *fmt, ...)
16
{
17
va_list ap;
18
19
if(!logfile) {
20
if(!(logfile = fopen(LOGFNAME, "w"))) {
21
return;
22
}
23
setvbuf(logfile, 0, _IOLBF, 0);
24
}
25
26
va_start(ap, fmt);
27
vfprintf(logfile, fmt, ap);
28
va_end(ap);
29
fflush(logfile);
30
}