diff options
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..76ba469 --- /dev/null +++ b/src/log.c @@ -0,0 +1,37 @@ +#include "log.h" + +#include <stdio.h> +#include <stdarg.h> + +const char *LOGPATH = "/tmp/mysqlerl.log"; +static FILE *logfile = NULL; + +void +openlog() +{ + logfile = fopen(LOGPATH, "a"); +} + +void +closelog() +{ + fclose(logfile); +} + +void +logmsg(const char *format, ...) +{ + FILE *out = logfile; + va_list args; + + if (logfile == NULL) + out = stderr; + + va_start(args, format); + (void)vfprintf(out, format, args); + (void)fprintf(out, "\n"); + va_end(args); + + fflush(out); +} + |