提交 21fcb164 authored 作者: Michael Jerris's avatar Michael Jerris

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
上级 3c9cb00a
Tue Mar 24 10:38:12 CDT 2009 Tue Mar 24 10:39:35 CDT 2009
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "s2util.h" #include "s2util.h"
#include <string.h>
#include <stdio.h>
/* -- Delay scenarios --------------------------------------------------- */ /* -- Delay scenarios --------------------------------------------------- */
static unsigned long time_offset; static unsigned long time_offset;
...@@ -49,3 +52,23 @@ void s2_fast_forward(unsigned long seconds, ...@@ -49,3 +52,23 @@ void s2_fast_forward(unsigned long seconds,
su_root_step(root, 0); 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);
}
...@@ -34,10 +34,12 @@ ...@@ -34,10 +34,12 @@
*/ */
#include <sofia-sip/su_wait.h> #include <sofia-sip/su_wait.h>
#include <stdarg.h>
SOFIA_BEGIN_DECLS SOFIA_BEGIN_DECLS
void s2_fast_forward(unsigned long seconds, su_root_t *root); 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 SOFIA_END_DECLS
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论