From 3c06dc67f9b946382430b1654935ebecdf6d25fb Mon Sep 17 00:00:00 2001 From: barbieri Date: Fri, 4 Sep 2009 01:43:50 +0000 Subject: [PATCH] loggify list. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@42221 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/eina_list.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/lib/eina_list.c b/src/lib/eina_list.c index 60be26d..5280518 100644 --- a/src/lib/eina_list.c +++ b/src/lib/eina_list.c @@ -154,6 +154,10 @@ struct _Eina_Accessor_List static int _eina_list_init_count = 0; static Eina_Mempool *_eina_list_mp = NULL; static Eina_Mempool *_eina_list_accounting_mp = NULL; +static int _eina_list_log_dom = -1; + +#define ERR(...) EINA_LOG_DOM_ERR(_eina_list_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_eina_list_log_dom, __VA_ARGS__) static inline Eina_List_Accounting* _eina_list_mempool_accounting_new(__UNUSED__ Eina_List *list) @@ -462,28 +466,41 @@ eina_list_init(void) if (!_eina_list_init_count) { - if (!eina_error_init()) + if (!eina_log_init()) { - fprintf(stderr, "Could not initialize eina error module\n"); + fprintf(stderr, "Could not initialize eina logging system.\n"); return 0; } - if (!eina_safety_checks_init()) + _eina_list_log_dom = eina_log_domain_register("eina_list", EINA_LOG_COLOR_DEFAULT); + if (_eina_list_log_dom < 0) { - fprintf(stderr, "Could not initialize eina safety checks.\n"); - eina_error_shutdown(); + EINA_LOG_ERR("Could not register log domain: eina_list"); + eina_log_shutdown(); return 0; } + if (!eina_error_init()) + { + ERR("Could not initialize eina error module."); + goto on_error_fail; + } + + if (!eina_safety_checks_init()) + { + ERR("Could not initialize eina safety checks."); + goto on_safety_checks_fail; + } + if (!eina_magic_string_init()) { - EINA_ERROR_PERR("ERROR: Could not initialize eina magic string module.\n"); + ERR("ERROR: Could not initialize eina magic string module."); goto on_magic_string_fail; } if (!eina_mempool_init()) { - EINA_ERROR_PERR("ERROR: Could not initialize eina mempool module.\n"); + ERR("ERROR: Could not initialize eina mempool module."); goto on_mempool_fail; } @@ -498,14 +515,14 @@ eina_list_init(void) sizeof (Eina_List), 320); if (!_eina_list_mp) { - EINA_ERROR_PERR("ERROR: Mempool for list cannot be allocated in list init.\n"); + ERR("ERROR: Mempool for list cannot be allocated in list init."); goto on_init_fail; } _eina_list_accounting_mp = eina_mempool_add(choice, "list_accounting", NULL, sizeof (Eina_List_Accounting), 80); if (!_eina_list_accounting_mp) { - EINA_ERROR_PERR("ERROR: Mempool for list accounting cannot be allocated in list init.\n"); + ERR("ERROR: Mempool for list accounting cannot be allocated in list init."); eina_mempool_del(_eina_list_mp); goto on_init_fail; } @@ -531,7 +548,13 @@ eina_list_init(void) on_mempool_fail: eina_magic_string_shutdown(); on_magic_string_fail: + eina_safety_checks_shutdown(); + on_safety_checks_fail: eina_error_shutdown(); + on_error_fail: + eina_log_domain_unregister(_eina_list_log_dom); + _eina_list_log_dom = -1; + eina_log_shutdown(); return 0; } @@ -560,6 +583,9 @@ eina_list_shutdown(void) eina_magic_string_shutdown(); eina_safety_checks_shutdown(); eina_error_shutdown(); + eina_log_domain_unregister(_eina_list_log_dom); + _eina_list_log_dom = -1; + eina_log_shutdown(); } return _eina_list_init_count; -- 2.7.4