From 81bc1d7af5886089bcd065382476f202ad7cc9ea Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Wed, 18 Jul 2007 19:47:20 +0000 Subject: Merge in ast_strftime branch, which changes timestamps to be accurate to the microsecond, instead of only to the second git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75706 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/logger.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'main/logger.c') diff --git a/main/logger.c b/main/logger.c index 1c7ef56a4..6a35ac5fe 100644 --- a/main/logger.c +++ b/main/logger.c @@ -866,8 +866,8 @@ void ast_log(int level, const char *file, int line, const char *function, const { struct logmsg *logmsg = NULL; struct ast_str *buf = NULL; - struct tm tm; - time_t t; + struct ast_tm tm; + struct timeval tv = ast_tvnow(); int res = 0; va_list ap; @@ -929,9 +929,8 @@ void ast_log(int level, const char *file, int line, const char *function, const logmsg->type = LOGMSG_NORMAL; /* Create our date/time */ - time(&t); - ast_localtime(&t, &tm, NULL); - strftime(logmsg->date, sizeof(logmsg->date), dateformat, &tm); + ast_localtime(&tv, &tm, NULL); + ast_strftime(logmsg->date, sizeof(logmsg->date), dateformat, &tm); /* Copy over data */ logmsg->level = level; @@ -993,14 +992,14 @@ void ast_verbose(const char *fmt, ...) return; if (ast_opt_timestamp) { - time_t t; - struct tm tm; + struct timeval tv; + struct ast_tm tm; char date[40]; char *datefmt; - time(&t); - ast_localtime(&t, &tm, NULL); - strftime(date, sizeof(date), dateformat, &tm); + tv = ast_tvnow(); + ast_localtime(&tv, &tm, NULL); + ast_strftime(date, sizeof(date), dateformat, &tm); datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1); sprintf(datefmt, "[%s] %s", date, fmt); fmt = datefmt; -- cgit v1.2.3