Thu Mar 5 13:20:53 CST 2009 Pekka Pessi <first.last@nokia.com>

* 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
This commit is contained in:
Michael Jerris 2009-03-24 15:40:31 +00:00
parent 3c9cb00a4b
commit 21fcb16428
3 changed files with 26 additions and 1 deletions

View File

@ -1 +1 @@
Tue Mar 24 10:38:12 CDT 2009
Tue Mar 24 10:39:35 CDT 2009

View File

@ -26,6 +26,9 @@
#include "s2util.h"
#include <string.h>
#include <stdio.h>
/* -- 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);
}

View File

@ -34,10 +34,12 @@
*/
#include <sofia-sip/su_wait.h>
#include <stdarg.h>
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