Commit 1e566fd2 authored by Pekka Pessi's avatar Pekka Pessi

s2util.h, s2time.c: added s2_timed_logger()

Ignore-this: 504e7e5c1201b0b2d5c345c31d5d4b71

darcs-hash:20090305192053-db55f-e22bdb798f63f6b614d0853f916478c45c37f299.gz
parent c6c96405
......@@ -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);
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment