Commit a46443b2 authored by Cedric Roux's avatar Cedric Roux

T: textlog: add option to dump 'raw time'

'raw time' is the tv_sec element in the struct tm
as returned by 'localtime'.

This can be useful to extract events from a dump based on their time.
parent f6f6570d
...@@ -30,6 +30,7 @@ void framelog_set_skip(logger *_this, int skip_delay); ...@@ -30,6 +30,7 @@ void framelog_set_skip(logger *_this, int skip_delay);
void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9); void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9);
void textlog_dump_buffer(logger *_this, int dump_buffer); void textlog_dump_buffer(logger *_this, int dump_buffer);
void textlog_raw_time(logger *_this, int raw_time);
#include "view/view.h" #include "view/view.h"
......
...@@ -33,6 +33,7 @@ struct textlog { ...@@ -33,6 +33,7 @@ struct textlog {
/* local output buffer */ /* local output buffer */
OBUF o; OBUF o;
int dump_buffer; int dump_buffer;
int raw_time;
}; };
static void _event(void *p, event e) static void _event(void *p, event e)
...@@ -51,9 +52,13 @@ static void _event(void *p, event e) ...@@ -51,9 +52,13 @@ static void _event(void *p, event e)
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
t = localtime(&e.sending_time.tv_sec); t = localtime(&e.sending_time.tv_sec);
/* round tv_nsec to nearest millisecond */ if (l->raw_time)
sprintf(tt, "%2.2d:%2.2d:%2.2d.%9.9ld: ", t->tm_hour, t->tm_min, t->tm_sec, sprintf(tt, "%2.2d:%2.2d:%2.2d.%9.9ld [%ld]: ",
e.sending_time.tv_nsec); t->tm_hour, t->tm_min, t->tm_sec,
e.sending_time.tv_nsec, e.sending_time.tv_sec);
else
sprintf(tt, "%2.2d:%2.2d:%2.2d.%9.9ld: ", t->tm_hour, t->tm_min, t->tm_sec,
e.sending_time.tv_nsec);
PUTS(&l->o, tt); PUTS(&l->o, tt);
#endif #endif
...@@ -215,3 +220,9 @@ void textlog_dump_buffer(logger *_this, int dump_buffer) ...@@ -215,3 +220,9 @@ void textlog_dump_buffer(logger *_this, int dump_buffer)
struct textlog *l = _this; struct textlog *l = _this;
l->dump_buffer = dump_buffer; l->dump_buffer = dump_buffer;
} }
void textlog_raw_time(logger *_this, int raw_time)
{
struct textlog *l = _this;
l->raw_time = raw_time;
}
...@@ -52,6 +52,7 @@ void usage(void) ...@@ -52,6 +52,7 @@ void usage(void)
" they will be processed in order\n" " they will be processed in order\n"
" by default, all is off\n" " by default, all is off\n"
" -full also dump buffers' content\n" " -full also dump buffers' content\n"
" -raw-time also prints 'raw time'\n"
" -ip <host> connect to given IP address (default %s)\n" " -ip <host> connect to given IP address (default %s)\n"
" -p <port> connect to given port (default %d)\n" " -p <port> connect to given port (default %d)\n"
" -x GUI output\n" " -x GUI output\n"
...@@ -91,6 +92,7 @@ int main(int n, char **v) ...@@ -91,6 +92,7 @@ int main(int n, char **v)
int gui_active = 1; int gui_active = 1;
textlog_data textlog_data; textlog_data textlog_data;
int full = 0; int full = 0;
int raw_time = 0;
/* write on a socket fails if the other end is closed and we get SIGPIPE */ /* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort(); if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
...@@ -117,6 +119,7 @@ int main(int n, char **v) ...@@ -117,6 +119,7 @@ int main(int n, char **v)
if (!strcmp(v[i], "-debug-gui")) { gui_logd = 1; continue; } if (!strcmp(v[i], "-debug-gui")) { gui_logd = 1; continue; }
if (!strcmp(v[i], "-no-gui")) { gui_active = 0; continue; } if (!strcmp(v[i], "-no-gui")) { gui_active = 0; continue; }
if (!strcmp(v[i], "-full")) { full = 1; continue; } if (!strcmp(v[i], "-full")) { full = 1; continue; }
if (!strcmp(v[i], "-raw-time")) { raw_time = 1; continue; }
usage(); usage();
} }
...@@ -162,6 +165,7 @@ int main(int n, char **v) ...@@ -162,6 +165,7 @@ int main(int n, char **v)
// "ev: {} eNB_id [eNB_ID] frame [frame] subframe [subframe]"); // "ev: {} eNB_id [eNB_ID] frame [frame] subframe [subframe]");
logger_add_view(textlog, out); logger_add_view(textlog, out);
if (full) textlog_dump_buffer(textlog, 1); if (full) textlog_dump_buffer(textlog, 1);
if (raw_time) textlog_raw_time(textlog, 1);
free(name); free(name);
free(desc); free(desc);
} }
......
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