diff options
author | David Troy <dave@popvox.com> | 2006-04-01 16:18:31 +0000 |
---|---|---|
committer | David Troy <dave@popvox.com> | 2006-04-01 16:18:31 +0000 |
commit | 7c49108130d3a186e505f7ddf0466991ba9fa089 (patch) | |
tree | 9cf93b7882ac608c749be5503b5594e4c1ee9abd /log.c | |
parent | e5e2fa3d3db461409b9b0554acadeee6f69fa18a (diff) | |
download | astmanproxy-7c49108130d3a186e505f7ddf0466991ba9fa089.tar.gz astmanproxy-7c49108130d3a186e505f7ddf0466991ba9fa089.tar.xz astmanproxy-7c49108130d3a186e505f7ddf0466991ba9fa089.zip |
Populating trunk
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/trunk@27 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,57 @@ +#include "astmanproxy.h" + +#define DATEFORMAT "%b %e %T" + +extern FILE *proxylog; +extern int debug; +extern pthread_mutex_t loglock; +extern pthread_mutex_t debuglock; + +void debugmsg (const char *fmt, ...) +{ + va_list ap; + + time_t t; + struct tm tm; + char date[80]; + + if (!debug) + return; + + time(&t); + localtime_r(&t, &tm); + strftime(date, sizeof(date), DATEFORMAT, &tm); + + pthread_mutex_lock(&debuglock); + va_start(ap, fmt); + printf("%s: ", date); + vprintf(fmt, ap); + printf("\n"); + va_end(ap); + pthread_mutex_unlock(&debuglock); +} + + +void logmsg (const char *fmt, ...) +{ + va_list ap; + + time_t t; + struct tm tm; + char date[80]; + + time(&t); + localtime_r(&t, &tm); + strftime(date, sizeof(date), DATEFORMAT, &tm); + + if (proxylog) { + pthread_mutex_lock(&loglock); + va_start(ap, fmt); + fprintf(proxylog, "%s: ", date); + vfprintf(proxylog, fmt, ap); + fprintf(proxylog, "\n"); + va_end(ap); + fflush(proxylog); + pthread_mutex_unlock(&loglock); + } +} |