barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=83425483569bb63528e0616f36006f6ec2cb14fe

commit 83425483569bb63528e0616f36006f6ec2cb14fe
Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi>
Date:   Tue Dec 6 14:00:55 2016 -0200

    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
---
 src/bin/eina/eina_btlog.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/bin/eina/eina_btlog.c b/src/bin/eina/eina_btlog.c
index fff97d8..0be9301 100644
--- a/src/bin/eina/eina_btlog.c
+++ b/src/bin/eina/eina_btlog.c
@@ -432,10 +432,17 @@ main(int argc, char **argv)
         return 1;
      }
 
+ repeat:
    while (fgets(buf, sizeof(buf) - 1, stdin))
      {
         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)
      {
         if (!bt->bin_dir) continue;
@@ -456,6 +463,8 @@ main(int argc, char **argv)
         len = strlen(bt->func_name);
         if (len > cols[5]) cols[5] = len;
      }
+
+ do_show:
    EINA_LIST_FOREACH(btl, l, bt)
      {
         if (bt->comment && show_comments)
@@ -505,6 +514,8 @@ main(int argc, char **argv)
         free(bt->comment);
         free(bt);
      }
+   /* if not EOF, then we just flushed due non-bt line, try again */
+   if (!feof(stdin)) goto repeat;
 
    eina_shutdown();
 

-- 


Reply via email to