Commit 8827261b authored by Pekka Pessi's avatar Pekka Pessi
Browse files

test_ops.c: added timestamp to event logging

darcs-hash:20070723151933-65a35-2203ac67720622b45b9009b0b3568c7aeec5b8e4.gz
parent f2712512
...@@ -146,47 +146,59 @@ void print_event(nua_event_t event, ...@@ -146,47 +146,59 @@ void print_event(nua_event_t event,
tagi_t tags[]) tagi_t tags[])
{ {
tagi_t const *t; tagi_t const *t;
static su_nanotime_t started = 0;
su_nanotime_t now;
char timestamp[32];
su_nanotime(&now);
if (started == 0) started = now;
now -= started; now /= 1000000;
snprintf(timestamp, sizeof timestamp, "%03u.%03u",
(unsigned)(now / 1000), (unsigned)(now % 1000));
if (event == nua_i_state) { if (event == nua_i_state) {
fprintf(stderr, "%s.nua(%p): event %s %s\n", fprintf(stderr, "%s %s.nua(%p): event %s %s\n", timestamp,
ep->name, (void *)nh, nua_event_name(event), ep->name, (void *)nh, nua_event_name(event),
nua_callstate_name(callstate(tags))); nua_callstate_name(callstate(tags)));
} }
else if ((int)event >= nua_r_set_params) { else if ((int)event >= nua_r_set_params) {
t = tl_find(tags, nutag_substate); t = tl_find(tags, nutag_substate);
if (t) { if (t) {
fprintf(stderr, "%s.nua(%p): event %s status %u %s (%s)\n", fprintf(stderr, "%s %s.nua(%p): event %s status %u %s (%s)\n", timestamp,
ep->name, (void*)nh, nua_event_name(event), status, phrase, ep->name, (void*)nh, nua_event_name(event), status, phrase,
nua_substate_name(t->t_value)); nua_substate_name(t->t_value));
} }
else { else {
fprintf(stderr, "%s.nua(%p): event %s status %u %s\n", fprintf(stderr, "%s %s.nua(%p): event %s status %u %s\n", timestamp,
ep->name, (void *)nh, nua_event_name(event), status, phrase); ep->name, (void *)nh, nua_event_name(event), status, phrase);
} }
} }
else if (event == nua_i_notify) { else if (event == nua_i_notify) {
t = tl_find(tags, nutag_substate); t = tl_find(tags, nutag_substate);
fprintf(stderr, "%s.nua(%p): event %s %s (%s)\n", fprintf(stderr, "%s %s.nua(%p): event %s %s (%s)\n", timestamp,
ep->name, (void *)nh, nua_event_name(event), phrase, ep->name, (void *)nh, nua_event_name(event), phrase,
nua_substate_name(t ? t->t_value : 0)); nua_substate_name(t ? t->t_value : 0));
} }
else if ((int)event >= 0) { else if ((int)event >= 0) {
fprintf(stderr, "%s.nua(%p): event %s %s\n", fprintf(stderr, "%s %s.nua(%p): event %s %s\n", timestamp,
ep->name, (void *)nh, nua_event_name(event), phrase); ep->name, (void *)nh, nua_event_name(event), phrase);
} }
else if (status > 0) { else if (status > 0) {
fprintf(stderr, "%s.nua(%p): call %s() with status %u %s\n", fprintf(stderr, "%s %s.nua(%p): call %s() with status %u %s\n", timestamp,
ep->name, (void *)nh, operation, status, phrase); ep->name, (void *)nh, operation, status, phrase);
} }
else { else {
t = tl_find(tags, siptag_subject_str); t = tl_find(tags, siptag_subject_str);
if (t && t->t_value) { if (t && t->t_value) {
char const *subject = (char const *)t->t_value; char const *subject = (char const *)t->t_value;
fprintf(stderr, "%s.nua(%p): call %s() \"%s\"\n", fprintf(stderr, "%s %s.nua(%p): call %s() \"%s\"\n", timestamp,
ep->name, (void *)nh, operation, subject); ep->name, (void *)nh, operation, subject);
} }
else else
fprintf(stderr, "%s.nua(%p): call %s()\n", fprintf(stderr, "%s %s.nua(%p): call %s()\n", timestamp,
ep->name, (void *)nh, operation); ep->name, (void *)nh, operation);
} }
......
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