forked from enlightenment/efl
eina_btlog: allows continuous running on input, flush when possible.
eina_btlog will make a table of the backtrace and then must compute columns length. However, if not running in such mode (ie: show_compact/-c), we don't need to queue lines or compute column lengths. Also, now that we accept non-backtrace lines, like other output interleaved, then flush the table once such line is found, this will restart the table columns for the next output, but at least allows eina_btlog to run on a live output, such as: myapp 2>&1 | eina_btlog
This commit is contained in:
parent
f0e13ccad9
commit
8342548356
|
@ -432,10 +432,17 @@ main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repeat:
|
||||||
while (fgets(buf, sizeof(buf) - 1, stdin))
|
while (fgets(buf, sizeof(buf) - 1, stdin))
|
||||||
{
|
{
|
||||||
btl = bt_append(btl, buf);
|
btl = bt_append(btl, buf);
|
||||||
|
if (show_compact) goto do_show;
|
||||||
|
bt = eina_list_last_data_get(btl);
|
||||||
|
if (bt && !bt->bin_dir) break; /* flush once first non-bt is found */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* compute columns for expanded display */
|
||||||
|
for (i = 0; i < 6; i++) cols[i] = 0;
|
||||||
EINA_LIST_FOREACH(btl, l, bt)
|
EINA_LIST_FOREACH(btl, l, bt)
|
||||||
{
|
{
|
||||||
if (!bt->bin_dir) continue;
|
if (!bt->bin_dir) continue;
|
||||||
|
@ -456,6 +463,8 @@ main(int argc, char **argv)
|
||||||
len = strlen(bt->func_name);
|
len = strlen(bt->func_name);
|
||||||
if (len > cols[5]) cols[5] = len;
|
if (len > cols[5]) cols[5] = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_show:
|
||||||
EINA_LIST_FOREACH(btl, l, bt)
|
EINA_LIST_FOREACH(btl, l, bt)
|
||||||
{
|
{
|
||||||
if (bt->comment && show_comments)
|
if (bt->comment && show_comments)
|
||||||
|
@ -505,6 +514,8 @@ main(int argc, char **argv)
|
||||||
free(bt->comment);
|
free(bt->comment);
|
||||||
free(bt);
|
free(bt);
|
||||||
}
|
}
|
||||||
|
/* if not EOF, then we just flushed due non-bt line, try again */
|
||||||
|
if (!feof(stdin)) goto repeat;
|
||||||
|
|
||||||
eina_shutdown();
|
eina_shutdown();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue