From 21fcb16428a72c7057fc5daef63d12af1354e756 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 24 Mar 2009 15:40:31 +0000 Subject: [PATCH] Thu Mar 5 13:20:53 CST 2009 Pekka Pessi * s2util.h, s2time.c: added s2_timed_logger() Ignore-this: 504e7e5c1201b0b2d5c345c31d5d4b71 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12741 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/s2check/s2time.c | 23 +++++++++++++++++++++++ libs/sofia-sip/s2check/s2util.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 4238df3ed3..c631fa1752 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Mar 24 10:38:12 CDT 2009 +Tue Mar 24 10:39:35 CDT 2009 diff --git a/libs/sofia-sip/s2check/s2time.c b/libs/sofia-sip/s2check/s2time.c index ccb075905e..dd9a914e1d 100644 --- a/libs/sofia-sip/s2check/s2time.c +++ b/libs/sofia-sip/s2check/s2time.c @@ -26,6 +26,9 @@ #include "s2util.h" +#include +#include + /* -- Delay scenarios --------------------------------------------------- */ static unsigned long time_offset; @@ -49,3 +52,23 @@ void s2_fast_forward(unsigned long seconds, su_root_step(root, 0); } +void +s2_timed_logger(void *stream, char const *fmt, va_list ap) +{ + char buffer[4096]; + su_time_t now = su_now(); + size_t prefix, wrote; + int n; + + snprintf(buffer, sizeof buffer, + "%02u:%02u:%02u.%06lu[+%lu] ", + (unsigned)(now.tv_sec / 3600 % 24), + (unsigned)(now.tv_sec / 60 % 60), + (unsigned)(now.tv_sec % 60), + now.tv_usec, + time_offset); + prefix = strlen(buffer); + n = vsnprintf(buffer + prefix, (sizeof buffer) - prefix, fmt, ap); + if (n > 0) + wrote = fwrite(buffer, prefix + n, 1, stream); +} diff --git a/libs/sofia-sip/s2check/s2util.h b/libs/sofia-sip/s2check/s2util.h index c991342f91..547d73602f 100644 --- a/libs/sofia-sip/s2check/s2util.h +++ b/libs/sofia-sip/s2check/s2util.h @@ -34,10 +34,12 @@ */ #include +#include SOFIA_BEGIN_DECLS void s2_fast_forward(unsigned long seconds, su_root_t *root); +void s2_timed_logger(void *stream, char const *fmt, va_list ap); SOFIA_END_DECLS