aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
blob: d03d86eaf27b96d17d76271761d6a001e7bdd210 (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
38
39
40
41
/*
 * Copyright (C) 2008, Brian Cully <bjc@kublai.com>
 */

#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);
}