Hello,

As my previous message said I think I understand the changes to do but 
to be sure i would like to try with one example of my own. For this I 
take the function eina_array_init() for the eina_array.c file.

the original code is this one (minus uninteresting details for the 
discussion)

EAPI int eina_array_init(void)
{
    if (!_eina_array_init_count)
      {
         if (!eina_error_init())
           {
              fprintf(stderr, "Could not initialize eina error module.\n");
              return 0;
           }

         if (!eina_magic_string_init())
           {
              EINA_ERROR_PERR("ERROR: Could not initialize eina magic 
string modu
le.\n");
              eina_error_shutdown();
              return 0;
            }
         /* */ do some stuff
     }
     return ;
}

the modified version is the following

EAPI int eina_array_init(void)
{
    if (!_eina_array_init_count)
      {
         if (!eina_error_init())
           {
              fprintf(stderr, "Could not initialize eina error module.\n");
              return 0;
           }
         if(!eina_log_init())
           {
              fprintf(stderr, "Could not initialize eina log module.\n");
              return 0;
           }
          if (!eina_magic_string_init())
           {
              EINA_LOG_ERR(EINA_LOG_DOMAIN_GLOBAL, "ERROR: Could not 
initialize eina magic string module.\n");
              eina_log_shutdown();
              eina_error_shutdown();
              return 0;
            }
         /* */ do some stuff
     }
     return ;
}

Now what is the difference between EINA_LOG_ERR and EINA_LOG_DOM_ERR in 
this case. Would it be wise to create an individual logging domain for 
each module or can we stick to the central logging domain defined in 
eina_log_init() function. Now in the following example, i can not delete 
the eina_error_init() function because some of the functions in the 
eina_array.c file use the eina_error_set function.

best

Mathieu
> On the beginning of a module, program or library, you must call 
> eina_log_init() for initializing the library. After that, you should 
> call eina_log_domain_register(domain_name, color) for registering a 
> new domain, note that this call returns an index associated with the 
> created domain. When your program is shutting down, it must unregister 
> registered domains and call eina_log_shutdown().
>
> Almost all files under 
> http://trac.enlightenment.org/e/browser/trunk/PROTO/eupnp/src/lib have 
> this pattern (init, register/save, shutdown). Also, note on 
> eupnp_log.c that I defined a global logging domain for the project. 
> There's a native global domain to which macros without DOM apply, but 
> if you want things customized like I do, you should do that way.
>
> A basic migration approach follows:
>
> 1. Find EINA_ERROR_P* macros and change them to the new ones: 
> EINA_LOG_DOM_* (grep :-))
> 2. Check if eina_error_set(), eina_error_msg_register() are being 
> used. If they aren't, you can remove eina_error_init() and 
> eina_error_shutdown(). Note that I found some libs using EINA_ERROR_ 
> macros and not calling eina_error_init().
>
>
> Hope this and code examples are enough. Any doubts please post on the ML.
>
> Thanks,
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to