From 6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 14 Apr 2008 21:52:55 -0400 Subject: Initial import --- server/.svn/text-base/log.c.svn-base | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 server/.svn/text-base/log.c.svn-base (limited to 'server/.svn/text-base/log.c.svn-base') diff --git a/server/.svn/text-base/log.c.svn-base b/server/.svn/text-base/log.c.svn-base new file mode 100644 index 0000000..612156d --- /dev/null +++ b/server/.svn/text-base/log.c.svn-base @@ -0,0 +1,99 @@ +#include "conf.h" +#include "log.h" + +#include +#include +#include +#include +#include +#include +#include + +RCSID("$Id: log.c,v 1.8 2000/11/13 18:47:17 shmit Exp $"); + +extern char *progname; + +#if 0 +FILE *logf = NULL; +#endif + +static void log_priority(int priority, const char *fmt, va_list args); + +/* + * Log a message with a given priority. + */ +void +log_priority(int priority, const char *fmt, va_list args) +{ + char lbuff[1024]; +#if 0 + char tbuff[256]; + struct tm timeptr; + time_t tloc; +#endif + + (void)snprintf(lbuff, sizeof(lbuff), + "[tid: %d] %s", (int)pthread_self(), fmt); + vsyslog(priority, lbuff, args); + +#if 0 + tloc = time(0); + (void)localtime_r(&tloc, &timeptr); + (void)strftime(tbuff, sizeof(tbuff), "%Y-%h-%d %H:%M:%S", &timeptr); + (void)snprintf(lbuff, sizeof(lbuff), "%s %s[%d:%d] %s\n", + tbuff, progname, getpid(), (int)pthread_self(), fmt); + (void)vfprintf(logf, lbuff, args); +#endif +} + +/* + * Log an error message. + */ +void +log_err(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_priority(LOG_ERR, fmt, ap); + va_end(ap); +} + +/* + * Log a warning message. + */ +void +log_warn(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_priority(LOG_WARNING, fmt, ap); + va_end(ap); +} + +/* + * Log an informational message. + */ +void +log_info(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_priority(LOG_INFO, fmt, ap); + va_end(ap); +} + +/* + * Initialize logging facilites. + */ +void +log_open() +{ + openlog(progname, LOG_PID|LOG_PERROR, LOG_DAEMON); + +#if 0 + logf = fopen("/home/shmit/var/log/nastd.log", "a+"); +#endif +} -- cgit v1.2.3