You are forcing it to a fixed File descriptor. Also you're imposing the
getenv() in every log function. Make it a global state that can be enabled
based on a numerical level. I'd also introduce a new backtrace function
that can be provided by user, or just a generic "post log" user function
that can contain a backtrace one, so maybe we can use it better.


On Wednesday, April 18, 2012, Enlightenment SVN wrote:

> Log:
> eina: add backtrace to Eina_Log.
>
>
> Author:       cedric
> Date:         2012-04-18 02:21:39 -0700 (Wed, 18 Apr 2012)
> New Revision: 70294
> Trac:         http://trac.enlightenment.org/e/changeset/70294
>
> Modified:
>  trunk/eina/src/lib/eina_log.c
>
> Modified: trunk/eina/src/lib/eina_log.c
> ===================================================================
> --- trunk/eina/src/lib/eina_log.c       2012-04-18 09:19:47 UTC (rev 70293)
> +++ trunk/eina/src/lib/eina_log.c       2012-04-18 09:21:39 UTC (rev 70294)
> @@ -28,6 +28,10 @@
>  #include <assert.h>
>  #include <errno.h>
>
> +#ifdef HAVE_EXECINFO_H
> +#include <execinfo.h>
> +#endif
> +
>  #ifdef HAVE_UNISTD_H
>  # include <unistd.h>
>  #endif
> @@ -1827,6 +1831,22 @@
>    _eina_log_print_prefix(stderr, d, level, file, fnc, line);
>    vfprintf(stderr, fmt, args);
>    putc('\n', stderr);
> +# if defined HAVE_BACKTRACE && defined HAVE_BACKTRACE_SYMBOLS
> +   if (getenv("EINA_LOG_BACKTRACE"))
> +     {
> +        void *bt[256];
> +       char **strings;
> +       int btlen;
> +       int i;
> +
> +       btlen = backtrace((void **)bt, 256);
> +       strings = backtrace_symbols((void **)bt, btlen);
> +       fprintf(stderr, "*** Backtrace ***\n");
> +       for (i = 0; i < btlen; ++i)
> +         fprintf(stderr, "%s\n", strings[i]);
> +       free(strings);
> +     }
> +# endif
>  #else
>    (void) d;
>    (void) level;
> @@ -1853,6 +1873,22 @@
>    _eina_log_print_prefix(stdout, d, level, file, fnc, line);
>    vprintf(fmt, args);
>    putchar('\n');
> +# if defined HAVE_BACKTRACE && defined HAVE_BACKTRACE_SYMBOLS
> +   if (getenv("EINA_LOG_BACKTRACE"))
> +     {
> +        void *bt[256];
> +       char **strings;
> +       int btlen;
> +       int i;
> +
> +       btlen = backtrace((void **)bt, 256);
> +       strings = backtrace_symbols((void **)bt, btlen);
> +       fprintf(stdout, "*** Backtrace ***\n");
> +       for (i = 0; i < btlen; ++i)
> +         fprintf(stdout, "%s\n", strings[i]);
> +       free(strings);
> +     }
> +# endif
>  #else
>    (void) d;
>    (void) level;
> @@ -1894,6 +1930,22 @@
>  #endif
>    fprintf(f, "%s<%u> %s:%d %s() ", d->name, eina_log_pid_get(),
>            file, line, fnc);
> +# if defined HAVE_BACKTRACE && defined HAVE_BACKTRACE_SYMBOLS
> +   if (getenv("EINA_LOG_BACKTRACE"))
> +     {
> +        void *bt[256];
> +       char **strings;
> +       int btlen;
> +       int i;
> +
> +       btlen = backtrace((void **)bt, 256);
> +       strings = backtrace_symbols((void **)bt, btlen);
> +       fprintf(f, "*** Backtrace ***\n");
> +       for (i = 0; i < btlen; ++i)
> +         fprintf(f, "%s\n", strings[i]);
> +       free(strings);
> +     }
> +# endif
>  #ifdef EFL_HAVE_THREADS
>  end:
>  #endif
> @@ -1991,3 +2043,4 @@
>    (void) args;
>  #endif
>  }
> +
>
>
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net <javascript:;>
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to