aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
blob: 76ba4695444c5f54ffc70f1f8aae0e90b9e69797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
}