diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-18 19:47:20 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-18 19:47:20 +0000 |
commit | 74c2948c2299773fd3816af43e06e3bdf714ba3a (patch) | |
tree | 540f82bac3e6105b6fc34cd4b4613c1756a7512b /main/logger.c | |
parent | fd471b4a0cbb2abd7b4c8f30fee850cedefedaa1 (diff) |
Merge in ast_strftime branch, which changes timestamps to be accurate to the microsecond, instead of only to the second
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75706 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/logger.c')
-rw-r--r-- | main/logger.c | 19 |
1 files changed, 9 insertions, 10 deletions
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; |