diff options
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 92 |
1 files changed, 51 insertions, 41 deletions
@@ -1,6 +1,16 @@ +/* Asterisk Manager Proxy + Copyright (c) 2005-2006 David C. Troy <dave@popvox.com> + + This program is free software, distributed under the terms of + the GNU General Public License. + + log.c + Log & debug routines +*/ + #include "astmanproxy.h" -#define DATEFORMAT "%b %e %T" +#define DATEFORMAT "%b %e %T" extern FILE *proxylog; extern int debug; @@ -9,49 +19,49 @@ 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); + 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); - } + 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); + } } |