From 50f3c688a7cd4819680dbd19b9933c6cb5e62ca7 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 6 Feb 2012 19:44:47 -0500 Subject: Move most files into lib, add top-level makefile --- src/log.c | 60 ------------------------------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 src/log.c (limited to 'src/log.c') diff --git a/src/log.c b/src/log.c deleted file mode 100644 index 80aa755..0000000 --- a/src/log.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008, Brian Cully - */ - -#include "log.h" - -#include -#include -#include -#include - -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; - char timebuf[32] = "\0"; - struct tm now_tm; - time_t now_time; - va_list args; - - va_start(args, format); - - if (logfile == NULL) - out = stderr; - - if (time(&now_time) == (time_t)-1) { - (void)fprintf(out, "LOGERROR - Failed to fetch time: "); - } else { - (void)localtime_r(&now_time, &now_tm); - if (strftime(timebuf, sizeof(timebuf), "%Y%m%d %H:%M:%S ", &now_tm) == 0) { - (void)fprintf(out, "LOGERROR - Failed to parse time (now: %d): ", - (int)now_time); - } else { - (void)fprintf(out, "%s", timebuf); - } - } - (void)fprintf(out, "[%d]: ", getpid()); - (void)vfprintf(out, format, args); - (void)fprintf(out, "\n"); - - fflush(out); - - va_end(args); -} - -- cgit v1.2.3