Enlightenment CVS committal

Author  : turran
Project : e17
Module  : proto/eina

Dir     : e17/proto/eina/src/lib


Modified Files:
        eina_error.c 


Log Message:
Allow user provided functions for printing messages
Make the stdout print mgs function exportable
Add a FILE * print msg function (useful for logging)

===================================================================
RCS file: /cvs/e/e17/proto/eina/src/lib/eina_error.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- eina_error.c        7 Aug 2008 13:09:09 -0000       1.6
+++ eina_error.c        8 Aug 2008 10:39:47 -0000       1.7
@@ -33,6 +33,8 @@
 static int _init_count = 0;
 static Eina_List *_error_list;
 static Eina_Error _err;
+static Eina_Error_Print_Cb _print_cb = eina_error_print_cb_stdout;
+static void *_print_cb_data = NULL;
 
 #define RED     "\033[31;1m"
 #define GREEN   "\033[32;1m"
@@ -55,17 +57,7 @@
        [EINA_ERROR_LEVEL_DBG] = GREEN,
 };
 
-static void _error_print(Eina_Error_Level level, const char *file,
-               const char *fnc, int line, const char *fmt, va_list args)
-{
-       if (level <= _error_level)
-       {
-               printf("%s", _colors[level]);
-               printf("[%s:%d] %s() ", file, line, fnc);
-               printf("%s", _colors[EINA_ERROR_LEVEL_INFO]);
-               vprintf(fmt, args);
-       }
-}
+
 /*============================================================================*
  *                                   API                                      
* 
  
*============================================================================*/
@@ -141,16 +133,49 @@
        return eina_list_nth(_error_list, error - 1);
 }
 /**
- * 
+ *
  */
-EAPI void eina_error_print(Eina_Error_Level level, const char *file, 
+EAPI void eina_error_print(Eina_Error_Level level, const char *file,
                const char *fnc, int line, const char *fmt, ...)
 {
        va_list args;
 
        va_start(args, fmt);
-       _error_print(level, file, fnc, line, fmt, args);
+       if (level <= _error_level)
+               _print_cb(level, file, fnc, line, fmt, _print_cb_data, args);
        va_end(args);
+}
+/**
+ *
+ */
+EAPI void eina_error_print_cb_stdout(Eina_Error_Level level, const char *file,
+               const char *fnc, int line, const char *fmt, void *data,
+               va_list args)
+{
+       printf("%s", _colors[level]);
+       printf("[%s:%d] %s() ", file, line, fnc);
+       printf("%s", _colors[EINA_ERROR_LEVEL_INFO]);
+       vprintf(fmt, args);
+}
+/**
+ *
+ */
+EAPI void eina_error_print_cb_file(Eina_Error_Level level, const char *file,
+               const char *fnc, int line, const char *fmt, void *data,
+               va_list args)
+{
+       FILE *f = data;
+
+       fprintf(f, "[%s:%d] %s() ", file, line, fnc);
+       vfprintf(f, fmt, args);
+}
+/**
+ *
+ */
+EAPI void eina_error_print_cb_set(Eina_Error_Print_Cb cb, void *data)
+{
+       _print_cb = cb;
+       _print_cb_data = data;
 }
 /**
  *



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to