summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2007-07-18 19:47:20 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2007-07-18 19:47:20 +0000
commit81bc1d7af5886089bcd065382476f202ad7cc9ea (patch)
tree540f82bac3e6105b6fc34cd4b4613c1756a7512b /main/logger.c
parentb96fde308cd75eb17e5fdb0ea6d54c0f1f593ff9 (diff)
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
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c19
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;