aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-03-02 11:44:52 -0500
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-03-02 11:44:52 -0500
commit4c31a79f1f76b6d80fffd05180dadcbb5a882293 (patch)
tree4452bb96e63748f0db3074f4f7f65bb8c19ed644 /src/log.c
parent26858b9722eb539cdb6fa762cb15071cfe753f45 (diff)
downloadmysqlerl-4c31a79f1f76b6d80fffd05180dadcbb5a882293.tar.gz
mysqlerl-4c31a79f1f76b6d80fffd05180dadcbb5a882293.zip
Move logger/io routines to separate modules.
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c37
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);
+}
+