Hello,

Herewith the patch that convert all log for eet to eina_log. Could one of the main dev checks and apply the patch to the tree please when he or she finds time. The default color should probably be modified (in eet_private.h file). I also follow the same rule than for the patch I send couple of days ago for efreet.

best

Mathieu
Index: src/lib/eet_lib.c
===================================================================
--- src/lib/eet_lib.c   (revision 42489)
+++ src/lib/eet_lib.c   (working copy)
@@ -142,6 +142,7 @@
    unsigned char         ciphered : 1;
 };
 
+
 #if 0
 /* Version 2 */
 /* NB: all int's are stored in network byte order on disk */
@@ -223,6 +224,9 @@
 static Eet_File **eet_readers         = NULL;
 static int        eet_initcount       = 0;
 
+/* log domain variable */
+int _eet_log_dom_global=-1;
+
 /* Check to see its' an eet file pointer */
 static inline int
 eet_check_pointer(const Eet_File *ef)
@@ -315,7 +319,7 @@
        new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File *));
        if (!new_cache)
          {
-            fprintf(stderr, "BAD ERROR! Eet realloc of cache list failed. 
Abort\n");
+            CRITICAL("BAD ERROR! Eet realloc of cache list failed. Abort\n");
             abort();
          }
      }
@@ -360,7 +364,7 @@
             new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File 
*));
             if (!new_cache)
               {
-                 fprintf(stderr, "BAD ERROR! Eet realloc of cache list failed. 
Abort\n");
+                 CRITICAL("BAD ERROR! Eet realloc of cache list failed. 
Abort\n");
                  abort();
               }
          }
@@ -758,17 +762,27 @@
 
    if (!eina_init())
      {
+       fprintf(stderr,"Eet: Eina init failed");
+       goto erro_eet_eina_init;
+     }
+   _eet_log_dom_global = eina_log_domain_register("Eet",EET_DEFAULT_LOG_COLOR);
+   if(_eet_log_dom_global < 0)
+     {
+       fprintf(stderr,"Eet Can not create a general log domain");
+       goto error_eet_eina_log;
+     }
+   return eet_initcount;
+ error_eet_eina_log:
+   eina_shutdown();
+ erro_eet_eina_init:
 #ifdef HAVE_GNUTLS
-       gnutls_global_deinit();
+   gnutls_global_deinit();
 #endif
 #ifdef HAVE_OPENSSL
-       EVP_cleanup();
-       ERR_free_strings();
+   EVP_cleanup();
+   ERR_free_strings();
 #endif
-       return 0;
-     }
-
-   return eet_initcount;
+   return 0;
 }
 
 EAPI int
@@ -779,7 +793,7 @@
    if (eet_initcount > 0) return eet_initcount;
 
    eet_clearcache();
-
+   eina_log_domain_unregister(_eet_log_dom_global);
    eina_shutdown();
 #ifdef HAVE_GNUTLS
    gnutls_global_deinit();
@@ -1060,7 +1074,7 @@
 
        if (eet_test_close(ef->x509_der == NULL, ef)) return NULL;
 #else
-       fprintf(stderr, "This file could be signed but you didn't compile the 
necessary code to check the signature.\n");
+       ERROR("This file could be signed but you didn't compile the necessary 
code to check the signature.\n");
 #endif
      }
 
@@ -1078,7 +1092,7 @@
    int                  byte_entries;
    int                  i;
 
-   fprintf(stderr, "EET file format of '%s' is deprecated. You should just 
open it one time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.\n", 
ef->path);
+   WARN("EET file format of '%s' is deprecated. You should just open it one 
time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.\n", ef->path);
 
    /* build header table if read mode */
    /* geat header */
@@ -1205,7 +1219,7 @@
             strncpy(efn->name, (char *)p + HEADER_SIZE, name_size);
             efn->name[name_size] = 0;
 
-            printf("File: %s is not up to date for key \"%s\" - needs 
rebuilding sometime\n", ef->path, efn->name);
+            WARN("File: %s is not up to date for key \"%s\" - needs rebuilding 
sometime\n", ef->path, efn->name);
          }
        else
          /* The only really usefull peace of code for efn->name (no backward 
compatibility) */
Index: src/lib/eet_data.c
===================================================================
--- src/lib/eet_data.c  (revision 42489)
+++ src/lib/eet_data.c  (working copy)
@@ -2020,7 +2020,7 @@
                                           else if (!strcmp(tok3, "hash"))      
n->type = EET_G_HASH;
                                           else
                                             {
-                                               printf("ERROR: group type '%s' 
invalid.\n", tok3);
+                                              ERR("ERROR: group type '%s' 
invalid.\n", tok3);
                                             }
                                           node = n;
                                        }
@@ -2132,7 +2132,7 @@
                                             }
                                           else
                                             {
-                                               printf("ERROR: value type '%s' 
invalid.\n", tok4);
+                                               ERR("ERROR: value type '%s' 
invalid.\n", tok4);
                                             }
                                        }
                                   }
Index: src/lib/eet_cipher.c
===================================================================
--- src/lib/eet_cipher.c        (revision 42489)
+++ src/lib/eet_cipher.c        (working copy)
@@ -272,7 +272,7 @@
        goto on_error;
       if (!(res = malloc(size))) goto on_error;
 
-      fprintf(out, "Private Key:\n");
+      INF("Private Key:\n");
       buf[32] = '\0';
 
       for (i = 0; i < 6; i++)
@@ -284,11 +284,11 @@
            }
          if (err) goto on_error;
 
-         fprintf(out, "\t%s:\n", names[i]);
+         INF("\t%s:\n", names[i]);
          for (j = 0; strlen(res) > j; j += 32)
            {
              snprintf(buf, 32, "%s", res + j);
-             fprintf(out, "\t\t%s\n", buf);
+             INF("\t\t%s\n", buf);
            }
        }
       free(res);
@@ -297,9 +297,9 @@
 
   if (key->certificate)
     {
-      fprintf(out, "Public certificate:\n");
+      INF("Public certificate:\n");
       if (gnutls_x509_crt_print(key->certificate, GNUTLS_X509_CRT_FULL, 
&data)) goto on_error;
-      fprintf(out, "%s", data.data);
+      INF("%s", data.data);
       gnutls_free(data.data);
       data.data = NULL;
     }
@@ -318,29 +318,29 @@
   rsa = EVP_PKEY_get1_RSA(key->private_key);
   if (rsa)
     {
-      fprintf(out, "Private key (RSA):\n");
+      INF("Private key (RSA):\n");
       RSA_print_fp(out, rsa, 0);
     }
 
   dsa = EVP_PKEY_get1_DSA(key->private_key);
   if (dsa)
     {
-      fprintf(out, "Private key (DSA):\n");
+      INF("Private key (DSA):\n");
       DSA_print_fp(out, dsa, 0);
     }
 
   dh = EVP_PKEY_get1_DH(key->private_key);
   if (dh)
     {
-      fprintf(out, "Private key (DH):\n");
+      INF("Private key (DH):\n");
       DHparams_print_fp(out, dh);
     }
 
-  fprintf(out, "Public certificate:\n");
+  INF("Public certificate:\n");
   X509_print_fp(out, key->certificate);
 # endif
 #else
-  fprintf(out, "You need to compile signature support in EET.\n");
+  INF("You need to compile signature support in EET.\n");
 #endif
 }
 
@@ -682,7 +682,7 @@
 #ifdef HAVE_SIGNATURE
   if (!certificate || !out || der_length <= 0)
      {
-       fprintf(out, "No certificate provided.\n");
+       INFO("No certificate provided.\n");
        return ;
      }
 # ifdef HAVE_GNUTLS
@@ -699,8 +699,8 @@
   datum.data = NULL;
   datum.size = 0;
   if (gnutls_x509_crt_print(cert, GNUTLS_X509_CRT_FULL, &datum)) goto on_error;
-  fprintf(out, "Public certificate :\n");
-  fprintf(out, "%s", datum.data);
+  INF("Public certificate :\n");
+  INF("%s", datum.data);
 
  on_error:
   if (datum.data) gnutls_free(datum.data);
@@ -715,17 +715,17 @@
    x509 = d2i_X509(NULL, &tmp, der_length);
    if (x509 == NULL)
      {
-       fprintf(out, "Not a valid certificate.\n");
+       INF("Not a valid certificate.\n");
        return ;
      }
 
-   fprintf(out, "Public certificate :\n");
+   INF("Public certificate :\n");
    X509_print_fp(out, x509);
 
    X509_free(x509);
 # endif
 #else
-   fprintf(out, "You need to compile signature support in EET.\n");
+   INF("You need to compile signature support in EET.\n");
 #endif
 }
 
Index: src/lib/Eet_private.h
===================================================================
--- src/lib/Eet_private.h       (revision 42489)
+++ src/lib/Eet_private.h       (working copy)
@@ -70,6 +70,80 @@
    } data;
 };
 
+/**  
+ * variable and macros used for the eina_log module
+ */
+extern int _eet_log_dom_global;
+
+#ifdef EET_DEFAULT_MODULE_LOG_DOMAIN
+#undef EET_DEFAULT_MODULE_LOG_DOMAIN _eet_log_dom_global
+#endif
+
+/**
+ * the default module log domain is the eet log domain 
+ */
+
+#define EET_DEFAULT_MODULE_LOG_DOMAIN _eet_log_dom_global
+
+/* Macros that are used everywhere 
+ *
+ * the first four macros are the general macros for the lib
+ */
+#ifdef EET_DEFAULT_LOG_COLOR
+#undef EET_DEFAULT_LOG_COLOR
+#endif
+#define EET_DEFAULT_LOG_COLOR "\033[36m"
+#ifdef ERROR
+#undef ERROR
+#endif
+#define ERROR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__)
+#ifdef DEBUG
+#undef DEBUG
+#endif
+#define DEBUG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__)
+#ifdef INFO
+#undef INFO
+#endif
+#define INFO(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__)
+#ifdef WARN
+#undef WARN
+#endif
+#define WARN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__)
+#ifdef CRITICAL
+#undef CRITICAL
+#endif
+#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__)
+/**
+ * macros that are used all around the code for message processing
+ * four macros are defined ERR, WRN, DGB, INF. 
+ * EFREET_MODULE_LOG_DOM should be defined individually for each module
+ */
+
+#ifdef _EET_MODULE_LOG_DOM
+#undef _EET_MODULE_LOG_DOM
+#endif
+#define _EET_MODULE_LOG_DOM _eet_log_dom_global /*default log domain for each 
module. It can redefined inside each module */
+#ifdef ERR
+#undef ERR
+#endif
+#define ERR(...) EINA_LOG_DOM_ERR(_EET_MODULE_LOG_DOM, __VA_ARGS__)
+#ifdef DBG
+#undef DBG
+#endif
+#define DBG(...) EINA_LOG_DOM_DBG(_EET_MODULE_LOG_DOM, __VA_ARGS__)
+#ifdef INF
+#undef INF
+#endif
+#define INF(...) EINA_LOG_DOM_INFO(_EET_MODULE_LOG_DOM, __VA_ARGS__)
+#ifdef WRN
+#undef WRN
+#endif
+#define WRN(...) EINA_LOG_DOM_WARN(_EET_MODULE_LOG_DOM, __VA_ARGS__)
+#ifdef CRIT
+#undef CRIT
+#endif
+#define CRIT(...) EINA_LOG_DOM_CRIT(_EET_MODULE_LOG_DOM, __VA_ARGS__)
+
 Eet_Dictionary  *eet_dictionary_add(void);
 void             eet_dictionary_free(Eet_Dictionary *ed);
 int              eet_dictionary_string_add(Eet_Dictionary *ed, const char 
*string);
------------------------------------------------------------------------------
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