* efreet: Use eina_log.

Patch from Matthieu.


SVN revision: 42599
This commit is contained in:
Cedric BAIL 2009-09-21 16:36:29 +00:00
parent c259d8addd
commit 05126826a3
13 changed files with 273 additions and 88 deletions

View File

@ -4,3 +4,4 @@ Sebastian 'englebass' Dransfeld
Nathan 'RbdPngn' Ingersoll Nathan 'RbdPngn' Ingersoll
Nicholas 'Mekius' Hughart Nicholas 'Mekius' Hughart
Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
Mathieu Taillefumier <mathieu.taillefumier@free.fr>

View File

@ -3,7 +3,7 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include <stdio.h>
#include <string.h> #include <string.h>
#include <Ecore_Str.h> #include <Ecore_Str.h>
@ -17,7 +17,7 @@ static int efreet_parsed_locale = 0;
static char *efreet_lang = NULL; static char *efreet_lang = NULL;
static char *efreet_lang_country = NULL; static char *efreet_lang_country = NULL;
static char *efreet_lang_modifier = NULL; static char *efreet_lang_modifier = NULL;
int _efreet_log_domain_global = -1;
static void efreet_parse_locale(void); static void efreet_parse_locale(void);
static int efreet_parse_locale_setting(const char *env); static int efreet_parse_locale_setting(const char *env);
@ -30,6 +30,12 @@ efreet_init(void)
{ {
if (init++) return init; if (init++) return init;
if (!eina_init()) return --init; if (!eina_init()) return --init;
_efreet_log_domain_global = eina_log_domain_register("Efreet",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_log_domain_global < 0)
{
printf("Efreet could create a general log domain.\n");
return --init;
}
if (!efreet_base_init()) return --init; if (!efreet_base_init()) return --init;
if (!efreet_xml_init()) return --init; if (!efreet_xml_init()) return --init;
if (!efreet_icon_init()) return --init; if (!efreet_icon_init()) return --init;
@ -55,6 +61,7 @@ efreet_shutdown(void)
efreet_icon_shutdown(); efreet_icon_shutdown();
efreet_xml_shutdown(); efreet_xml_shutdown();
efreet_base_shutdown(); efreet_base_shutdown();
eina_log_domain_unregister(_efreet_log_domain_global);
eina_shutdown(); eina_shutdown();
IF_FREE(efreet_lang); IF_FREE(efreet_lang);

View File

@ -23,6 +23,15 @@ static const char *xdg_cache_home = NULL;
static Eina_List *xdg_data_dirs = NULL; static Eina_List *xdg_data_dirs = NULL;
static Eina_List *xdg_config_dirs = NULL; static Eina_List *xdg_config_dirs = NULL;
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_base_log_dom
static int _efreet_base_log_dom = -1;
static const char *efreet_dir_get(const char *key, const char *fallback); static const char *efreet_dir_get(const char *key, const char *fallback);
static Eina_List *efreet_dirs_get(const char *key, static Eina_List *efreet_dirs_get(const char *key,
const char *fallback); const char *fallback);
@ -36,7 +45,13 @@ int
efreet_base_init(void) efreet_base_init(void)
{ {
if (!eina_init()) return 0; if (!eina_init()) return 0;
_efreet_base_log_dom = eina_log_domain_register("Efreet_base",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_base_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for efreet_base.\n");
eina_shutdown();
return 0;
}
return 1; return 1;
} }

View File

@ -1,7 +1,6 @@
/* vim: set sw=4 ts=4 sts=4 et: */ /* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_BASE_H #ifndef EFREET_BASE_H
#define EFREET_BASE_H #define EFREET_BASE_H
/** /**
* @file efreet_base.h * @file efreet_base.h
* @brief Contains the methods used to support the FDO base directory * @brief Contains the methods used to support the FDO base directory

View File

@ -47,6 +47,13 @@ static int efreet_desktop_command_file_id = 0;
static int init = 0; static int init = 0;
static int cache_flush = 0; static int cache_flush = 0;
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_desktop_log_dom
static int _efreet_desktop_log_dom = -1;
EAPI int EFREET_DESKTOP_TYPE_APPLICATION = 0; EAPI int EFREET_DESKTOP_TYPE_APPLICATION = 0;
EAPI int EFREET_DESKTOP_TYPE_LINK = 0; EAPI int EFREET_DESKTOP_TYPE_LINK = 0;
EAPI int EFREET_DESKTOP_TYPE_DIRECTORY = 0; EAPI int EFREET_DESKTOP_TYPE_DIRECTORY = 0;
@ -137,6 +144,13 @@ efreet_desktop_init(void)
{ {
if (init++) return init; if (init++) return init;
if (!eina_init()) return --init; if (!eina_init()) return --init;
_efreet_desktop_log_dom = eina_log_domain_register("Efreet_desktop",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_desktop_log_dom<0)
{
ERROR("Efreet: Could not create a log domain for Efreet_desktop");
eina_shutdown();
return --init;
}
if (!ecore_file_init()) return --init; if (!ecore_file_init()) return --init;
efreet_desktop_cache = eina_hash_string_superfast_new(NULL); efreet_desktop_cache = eina_hash_string_superfast_new(NULL);
@ -168,7 +182,7 @@ efreet_desktop_shutdown(void)
if (--init) return init; if (--init) return init;
ecore_file_shutdown(); ecore_file_shutdown();
eina_shutdown(); eina_shutdown();
eina_log_domain_unregister(_efreet_desktop_log_dom);
IF_RELEASE(desktop_environment); IF_RELEASE(desktop_environment);
IF_FREE_HASH(efreet_desktop_cache); IF_FREE_HASH(efreet_desktop_cache);
while (efreet_desktop_types) while (efreet_desktop_types)
@ -333,7 +347,7 @@ efreet_desktop_read(Efreet_Desktop *desktop)
if (!ok) ok = efreet_ini_section_set(ini, "KDE Desktop Entry"); if (!ok) ok = efreet_ini_section_set(ini, "KDE Desktop Entry");
if (!ok) if (!ok)
{ {
printf("efreet_desktop_new error: no Desktop Entry section\n"); ERR("efreet_desktop_new error: no Desktop Entry section");
error = 1; error = 1;
} }
@ -776,8 +790,8 @@ efreet_desktop_string_list_parse(const char *string)
if (*s) if (*s)
{ {
#ifdef STRICT_SPEC #ifdef STRICT_SPEC
printf("[Efreet]: Found a string list without ';' " WRN("[Efreet]: Found a string list without ';' "
"at the end: %s\n", string); "at the end: %s", string);
#endif #endif
list = eina_list_append(list, (void *)eina_stringshare_add(s)); list = eina_list_append(list, (void *)eina_stringshare_add(s));
} }
@ -959,7 +973,7 @@ efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
if (val) desktop->name = strdup(val); if (val) desktop->name = strdup(val);
else else
{ {
printf("efreet_desktop_generic_fields_parse error: no Name\n"); ERR("efreet_desktop_generic_fields_parse error: no Name");
return 0; return 0;
} }
@ -1396,7 +1410,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
break; break;
case 'v': case 'v':
case 'm': case 'm':
printf("[Efreet]: Deprecated conversion char: '%c' in file '%s'\n", WRN("[Efreet]: Deprecated conversion char: '%c' in file '%s'",
*p, command->desktop->orig_path); *p, command->desktop->orig_path);
break; break;
case '%': case '%':
@ -1404,7 +1418,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
break; break;
default: default:
#ifdef STRICT_SPEC #ifdef STRICT_SPEC
printf("[Efreet]: Unknown conversion character: '%c'\n", *p); WRN("[Efreet_desktop]: Unknown conversion character: '%c'", *p);
#endif #endif
break; break;
} }
@ -1421,7 +1435,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
*/ */
if ((file) && (!file_added)) if ((file) && (!file_added))
{ {
printf("[Efreet]: %s\n" WRN("Efreet_desktop: %s\n"
" command: %s\n" " command: %s\n"
" has no file path/uri spec info for executing this app WITH a\n" " has no file path/uri spec info for executing this app WITH a\n"
" file/uri as a parameter. This is unlikely to be the intent.\n" " file/uri as a parameter. This is unlikely to be the intent.\n"
@ -1543,8 +1557,8 @@ efreet_desktop_command_append_single(char *dest, int *size, int *len,
str = file->file; str = file->file;
break; break;
default: default:
printf("Invalid type passed to efreet_desktop_command_append_single:" ERR("Invalid type passed to efreet_desktop_command_append_single:"
" '%c'\n", type); " '%c'", type);
return dest; return dest;
} }
@ -1621,7 +1635,7 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
const char *uri, *base; const char *uri, *base;
int nonlocal = 0; int nonlocal = 0;
/* /*
printf("FLAGS: %d, %d, %d, %d\n", DBG("FLAGS: %d, %d, %d, %d\n",
command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH ? 1 : 0, command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH ? 1 : 0,
command->flags & EFREET_DESKTOP_EXEC_FLAG_URI ? 1 : 0, command->flags & EFREET_DESKTOP_EXEC_FLAG_URI ? 1 : 0,
command->flags & EFREET_DESKTOP_EXEC_FLAG_DIR ? 1 : 0, command->flags & EFREET_DESKTOP_EXEC_FLAG_DIR ? 1 : 0,
@ -1694,10 +1708,10 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
free(abs); free(abs);
} }
#if 0 #if 0
printf(" fullpath: %s\n", f->fullpath); INF(" fullpath: %s", f->fullpath);
printf(" uri: %s\n", f->uri); INF(" uri: %s", f->uri);
printf(" dir: %s\n", f->dir); INF(" dir: %s", f->dir);
printf(" file: %s\n", f->file); INF(" file: %s", f->file);
#endif #endif
return f; return f;
} }

View File

@ -97,6 +97,13 @@ static void efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, un
static Efreet_Icon_Theme *fake_null = NULL; static Efreet_Icon_Theme *fake_null = NULL;
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_icon_log_dom
static int _efreet_icon_log_dom = -1;
static void static void
_efreet_icon_cache_list_destroy(Eina_List *list) _efreet_icon_cache_list_destroy(Eina_List *list)
{ {
@ -326,7 +333,7 @@ efreet_icon_remove_extension(const char *icon)
if (!strcmp(ext, ext2)) if (!strcmp(ext, ext2))
{ {
#ifdef STRICT_SPEC #ifdef STRICT_SPEC
printf("[Efreet]: Requesting an icon with an extension: %s\n", WRN("[Efreet]: Requesting an icon with an extension: %s",
icon); icon);
#endif #endif
*ext = '\0'; *ext = '\0';
@ -908,7 +915,7 @@ efreet_icon_fallback_dir_scan(const char *dir, const char *icon_name)
icon = strdup(path); icon = strdup(path);
#ifdef STRICT_SPEC #ifdef STRICT_SPEC
if (icon) if (icon)
printf("[Efreet]: Found an icon that already has an extension: %s\n", path); WRN("[Efreet]: Found an icon that already has an extension: %s", path);
#endif #endif
} }
} }

View File

@ -32,9 +32,15 @@ void *alloca (size_t);
#include "Efreet.h" #include "Efreet.h"
#include "efreet_private.h" #include "efreet_private.h"
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_ini_log_dom
static int _efreet_ini_log_dom = -1;
static Eina_Hash *efreet_ini_parse(const char *file); static Eina_Hash *efreet_ini_parse(const char *file);
static char *efreet_ini_unescape(const char *str); static char *efreet_ini_unescape(const char *str);
static int _efreet_ini_log_om = -1;
static Eina_Bool static Eina_Bool
efreet_ini_section_save(const Eina_Hash *hash, const void *key, void *data, void *fdata); efreet_ini_section_save(const Eina_Hash *hash, const void *key, void *data, void *fdata);
static Eina_Bool static Eina_Bool
@ -55,6 +61,13 @@ efreet_ini_init(void)
{ {
if (init++) return init; if (init++) return init;
if (!eina_init()) return --init; if (!eina_init()) return --init;
_efreet_ini_log_dom = eina_log_domain_register("Efreet_init",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_ini_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for efreet_init");
eina_shutdown();
return --init;
}
return init; return init;
} }
@ -67,6 +80,7 @@ int
efreet_ini_shutdown(void) efreet_ini_shutdown(void)
{ {
if (--init) return init; if (--init) return init;
eina_log_domain_unregister(_efreet_ini_log_dom);
eina_shutdown(); eina_shutdown();
return init; return init;
} }
@ -184,8 +198,8 @@ efreet_ini_parse(const char *file)
section = eina_hash_string_small_new(free); section = eina_hash_string_small_new(free);
eina_hash_del(data, header, NULL); eina_hash_del(data, header, NULL);
// if (old) printf("[efreet] Warning: duplicate section '%s' " // if (old) INF("[efreet] Warning: duplicate section '%s' "
// "in file '%s'\n", header, file); // "in file '%s'", header, file);
eina_hash_add(data, header, section); eina_hash_add(data, header, section);
} }
@ -200,7 +214,7 @@ efreet_ini_parse(const char *file)
if (section == NULL) if (section == NULL)
{ {
// printf("Invalid file (%s) (missing section)\n", file); // INF("Invalid file (%s) (missing section)", file);
goto next_line; goto next_line;
} }
@ -242,7 +256,7 @@ efreet_ini_parse(const char *file)
if (key_end == 0) if (key_end == 0)
{ {
/* invalid file... */ /* invalid file... */
// printf("Invalid file (%s) (invalid key=value pair)\n", file); // INF("Invalid file (%s) (invalid key=value pair)", file);
goto next_line; goto next_line;
} }
@ -264,7 +278,7 @@ efreet_ini_parse(const char *file)
// else // else
// { // {
// /* invalid file... */ // /* invalid file... */
// printf("Invalid file (%s) (missing = from key=value pair)\n", file); // INF("Invalid file (%s) (missing = from key=value pair)", file);
// } // }
next_line: next_line:

View File

@ -234,6 +234,16 @@ static Eina_Hash *efreet_menu_filter_cbs = NULL;
static Eina_Hash *efreet_menu_move_cbs = NULL; static Eina_Hash *efreet_menu_move_cbs = NULL;
static Eina_Hash *efreet_menu_layout_cbs = NULL; static Eina_Hash *efreet_menu_layout_cbs = NULL;
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_menu_log_dom
static int _efreet_menu_log_dom = -1;
static const char *efreet_menu_prefix_get(void); static const char *efreet_menu_prefix_get(void);
static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal, static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal,
@ -451,6 +461,13 @@ efreet_menu_init(void)
}; };
if (!eina_init()) return 0; if (!eina_init()) return 0;
_efreet_menu_log_dom = eina_log_domain_register("Efreet_menu",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_menu_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for Efreet_mnenu");
eina_shutdown();
return 0;
}
if (!efreet_xml_init()) return 0; if (!efreet_xml_init()) return 0;
efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL); efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL);
@ -525,7 +542,7 @@ efreet_menu_kde_legacy_init(void)
* this won't be correct (increase buffer and get the rest...) */ * this won't be correct (increase buffer and get the rest...) */
if (!fgets(buf, PATH_MAX, f)) if (!fgets(buf, PATH_MAX, f))
{ {
printf("Error initializing KDE legacy information\n"); ERR("Error initializing KDE legacy information");
return 0; return 0;
} }
s = buf; s = buf;
@ -571,6 +588,7 @@ efreet_menu_shutdown(void)
IF_RELEASE(efreet_tag_menu); IF_RELEASE(efreet_tag_menu);
efreet_xml_shutdown(); efreet_xml_shutdown();
eina_log_domain_unregister(_efreet_menu_log_dom);
eina_shutdown(); eina_shutdown();
} }
@ -587,7 +605,7 @@ efreet_menu_new(const char *name)
if (!name) if (!name)
{ {
printf("Error creating a new menu, name is missing\n"); ERR("Efreet_menu: Error creating a new menu, name is missing");
return NULL; return NULL;
} }
menu = efreet_menu_entry_new(); menu = efreet_menu_entry_new();
@ -663,7 +681,7 @@ efreet_menu_parse(const char *path)
/* make sure we've got a <Menu> to start with */ /* make sure we've got a <Menu> to start with */
if (xml->tag != efreet_tag_menu) if (xml->tag != efreet_tag_menu)
{ {
printf("Menu file didn't start with <Menu> tag.\n"); WRN("Efreet_menu: Menu file didn't start with <Menu> tag.");
efreet_xml_del(xml); efreet_xml_del(xml);
return NULL; return NULL;
} }
@ -915,8 +933,8 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
{ {
Eina_List *l; Eina_List *l;
printf("%s%s: ", indent, menu->name); INF("%s%s: ", indent, menu->name);
printf("%s\n", (menu->icon ? menu->icon : "No icon")); INF("%s", (menu->icon ? menu->icon : "No icon"));
/* XXX dump the rest of the menu info */ /* XXX dump the rest of the menu info */
@ -933,13 +951,13 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
EINA_LIST_FOREACH(menu->entries, l, entry) EINA_LIST_FOREACH(menu->entries, l, entry)
{ {
if (entry->type == EFREET_MENU_ENTRY_SEPARATOR) if (entry->type == EFREET_MENU_ENTRY_SEPARATOR)
printf("%s|---\n", new_indent); INF("%s|---", new_indent);
else if (entry->type == EFREET_MENU_ENTRY_DESKTOP) else if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
printf("%s|-%s\n", new_indent, entry->name); INF("%s|-%s", new_indent, entry->name);
else if (entry->type == EFREET_MENU_ENTRY_MENU) else if (entry->type == EFREET_MENU_ENTRY_MENU)
efreet_menu_dump(entry, new_indent); efreet_menu_dump(entry, new_indent);
else if (entry->type == EFREET_MENU_ENTRY_HEADER) else if (entry->type == EFREET_MENU_ENTRY_HEADER)
printf("%s|---%s\n", new_indent, entry->name); INF("%s|---%s", new_indent, entry->name);
} }
FREE(new_indent); FREE(new_indent);
@ -1080,7 +1098,7 @@ efreet_menu_handle_menu(Efreet_Menu_Internal *internal, Efreet_Xml *xml)
} }
else else
{ {
printf("Unknown XML tag: %s\n", child->tag); WRN("Unknown XML tag: %s", child->tag);
return 0; return 0;
} }
} }
@ -1279,7 +1297,7 @@ efreet_menu_handle_name(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
/* not allowed to have two Name settings in a menu */ /* not allowed to have two Name settings in a menu */
if (parent->name.internal) if (parent->name.internal)
{ {
printf("efreet_menu_handle_name() setting second name into menu\n"); INF("efreet_menu_handle_name() setting second name into menu");
return 0; return 0;
} }
@ -1561,7 +1579,7 @@ efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
if (!parent->file.path) if (!parent->file.path)
{ {
printf("efreet_menu_handle_merge_file() missing menu path ...\n"); INF("efreet_menu_handle_merge_file() missing menu path ...");
return 0; return 0;
} }
@ -1588,8 +1606,8 @@ efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
if (!dir) if (!dir)
{ {
printf("efreet_menu_handle_merge_file() failed to find " INF("efreet_menu_handle_merge_file() failed to find "
"menu parent directory\n"); "menu parent directory");
return 0; return 0;
} }
@ -1645,7 +1663,7 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
realpath = ecore_file_realpath(path); realpath = ecore_file_realpath(path);
if (realpath[0] == '\0') if (realpath[0] == '\0')
{ {
printf("efreet_menu_merge() unable to get real path for %s\n", path); INF("efreet_menu_merge() unable to get real path for %s", path);
return 0; return 0;
} }
@ -1660,8 +1678,8 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
if (!merge_xml) if (!merge_xml)
{ {
printf("efreet_menu_merge() failed to read in the " INF("efreet_menu_merge() failed to read in the "
"merge file (%s)\n", realpath); "merge file (%s)", realpath);
return 0; return 0;
} }
@ -2038,8 +2056,8 @@ efreet_menu_handle_move(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
} }
else else
{ {
printf("efreet_menu_handle_move() unknown tag found " INF("efreet_menu_handle_move() unknown tag found "
"in Move (%s)\n", child->tag); "in Move (%s)", child->tag);
return 0; return 0;
} }
} }
@ -2065,8 +2083,8 @@ efreet_menu_handle_old(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
if (parent->current_move) if (parent->current_move)
{ {
printf("efreet_menu_handle_old() saw second <Old> " INF("efreet_menu_handle_old() saw second <Old> "
"before seeing <New>\n"); "before seeing <New>");
return 0; return 0;
} }
@ -2106,7 +2124,7 @@ efreet_menu_handle_new(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
if (!parent->current_move) if (!parent->current_move)
{ {
printf("efreet_menu_handle_new() saw New before seeing Old\n"); INF("efreet_menu_handle_new() saw New before seeing Old");
return 0; return 0;
} }
@ -2148,8 +2166,8 @@ efreet_menu_handle_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
} }
else else
{ {
printf("efreet_menu_handle_move() unknown tag found " INF("efreet_menu_handle_move() unknown tag found "
"in Layout (%s)\n", child->tag); "in Layout (%s)", child->tag);
return 0; return 0;
} }
} }
@ -2205,8 +2223,8 @@ efreet_menu_handle_default_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
} }
else else
{ {
printf("efreet_menu_handle_move() unknown tag found in " INF("efreet_menu_handle_move() unknown tag found in "
"DefaultLayout (%s)\n", child->tag); "DefaultLayout (%s)", child->tag);
return 0; return 0;
} }
} }
@ -2224,8 +2242,8 @@ efreet_menu_handle_layout_menuname(Efreet_Menu_Internal *parent, Efreet_Xml *xml
if (!xml->text) if (!xml->text)
{ {
printf("efreet_menu_handle_layout_menuname() The Menuname tag in " INF("efreet_menu_handle_layout_menuname() The Menuname tag in "
"layout needs a filename.\n"); "layout needs a filename.");
return 0; return 0;
} }
@ -2263,8 +2281,8 @@ efreet_menu_handle_layout_filename(Efreet_Menu_Internal *parent, Efreet_Xml *xml
if (!xml->text) if (!xml->text)
{ {
printf("efreet_menu_handle_layout_filename() The Filename tag in " INF("efreet_menu_handle_layout_filename() The Filename tag in "
"layout needs a filename.\n"); "layout needs a filename.");
return 0; return 0;
} }
@ -2305,15 +2323,15 @@ efreet_menu_handle_layout_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, i
attr = efreet_xml_attribute_get(xml, "type"); attr = efreet_xml_attribute_get(xml, "type");
if (!attr) if (!attr)
{ {
printf("efreet_menu_handle_layout_merge() The Merge tag in layout " INF("efreet_menu_handle_layout_merge() The Merge tag in layout "
"needs a type attribute.\n"); "needs a type attribute.");
return 0; return 0;
} }
if (strcmp(attr, "files") && strcmp(attr, "menus") && strcmp(attr, "all")) if (strcmp(attr, "files") && strcmp(attr, "menus") && strcmp(attr, "all"))
{ {
printf("efreet_menu_handle_layout_merge() The type attribute for " INF("efreet_menu_handle_layout_merge() The type attribute for "
"the Merge tag contains an unknown value (%s).\n", attr); "the Merge tag contains an unknown value (%s).", attr);
return 0; return 0;
} }
@ -2384,7 +2402,7 @@ efreet_menu_handle_filter_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
} }
else else
{ {
printf("efreet_menu_handle_filter_op() unknown tag in filter (%s)\n", child->tag); INF("efreet_menu_handle_filter_op() unknown tag in filter (%s)", child->tag);
return 0; return 0;
} }
} }
@ -3349,7 +3367,7 @@ efreet_menu_path_get(Efreet_Menu_Internal *internal, const char *suffix)
{ {
if (!internal->file.path) if (!internal->file.path)
{ {
printf("efreet_menu_handle_app_dir() missing menu path ...\n"); INF("efreet_menu_handle_app_dir() missing menu path ...");
return NULL; return NULL;
} }
snprintf(path, sizeof(path), "%s/%s", internal->file.path, suffix); snprintf(path, sizeof(path), "%s/%s", internal->file.path, suffix);

View File

@ -151,6 +151,14 @@ struct Efreet_Mime_Icon_Entry
unsigned int size; unsigned int size;
}; };
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_mime_log_dom
static int _efreet_mime_log_dom = -1;
static int efreet_mime_glob_remove(const char *glob); static int efreet_mime_glob_remove(const char *glob);
static void efreet_mime_mime_types_load(const char *file); static void efreet_mime_mime_types_load(const char *file);
@ -207,6 +215,14 @@ efreet_mime_init(void)
if (!efreet_init()) if (!efreet_init())
return 0; return 0;
_efreet_mime_log_dom = eina_log_domain_register("Efreet_mime",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_mime_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for Efreet_mime.");
return 0;
}
efreet_mime_endianess = efreet_mime_endian_check(); efreet_mime_endianess = efreet_mime_endian_check();
monitors = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_file_monitor_del)); monitors = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_file_monitor_del));
@ -241,7 +257,7 @@ efreet_mime_shutdown(void)
IF_FREE_HASH(monitors); IF_FREE_HASH(monitors);
IF_FREE_HASH(wild); IF_FREE_HASH(wild);
IF_FREE_HASH(mime_icons); IF_FREE_HASH(mime_icons);
eina_log_domain_unregister(_efreet_mime_log_dom);
efreet_shutdown(); efreet_shutdown();
ecore_file_shutdown(); ecore_file_shutdown();
ecore_shutdown(); ecore_shutdown();
@ -1559,11 +1575,11 @@ efreet_mime_icons_debug(void)
now = 0; now = 0;
} }
printf("mime-icon entry: '%s' last used: %s", DBG("mime-icon entry: '%s' last used: %s",
entry->mime, ctime(&entry->timestamp)); entry->mime, ctime(&entry->timestamp));
EINA_INLIST_FOREACH(entry->list, n) EINA_INLIST_FOREACH(entry->list, n)
printf("\tsize: %3u theme: '%s' icon: '%s'\n", DBG("\tsize: %3u theme: '%s' icon: '%s'",
n->theme, n->size, n->icon); n->theme, n->size, n->icon);
} }
} }

View File

@ -71,6 +71,57 @@
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
/**
* @def _efree_log_domain_global
* global log domain for efreet (see eina_log module)
*/
extern int _efreet_log_dom_global;
#ifdef EFREET_DEFAULT_LOG_COLOR
#undef EFREET_DEFAULT_LOG_COLOR
#endif
#define EFREET_DEFAULT_LOG_COLOR "\033[36m"
#define EFREET_MODULE_LOG_DOM _efreet_log_dom_global; /*default log domain for each module. It can redefined inside each module */
#ifdef ERROR
#undef ERROR
#endif
#define ERROR(...) EINA_LOG_DOM_ERR(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef DEBUG
#undef DEBUG
#endif
#define DEBUG(...) EINA_LOG_DOM_DBG(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef INFO
#undef INFO
#endif
#define INFO(...) EINA_LOG_DOM_INFO(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef WARN
#undef WARN
#endif
#define WARN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __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
*/
#define EFREET_MODULE_LOG_DOM _efreet_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(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef DBG
#undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef INF
#undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
#ifdef WRN
#undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
/** /**
* @internal * @internal
* The different types of commands in an Exec entry * The different types of commands in an Exec entry

View File

@ -16,6 +16,14 @@
static const char *efreet_trash_dir = NULL; static const char *efreet_trash_dir = NULL;
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_trash_log_dom
static int _efreet_trash_log_dom = -1;
/** /**
* @return Returns 1 on success or 0 on failure * @return Returns 1 on success or 0 on failure
* @brief Initializes the efreet trash system * @brief Initializes the efreet trash system
@ -23,6 +31,12 @@ static const char *efreet_trash_dir = NULL;
EAPI int EAPI int
efreet_trash_init(void) efreet_trash_init(void)
{ {
_efreet_trash_log_dom = eina_log_domain_register("Efreet_trash",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_trash_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for Efreet_trash");
return 0;
}
return 1; return 1;
} }
@ -34,6 +48,7 @@ EAPI void
efreet_trash_shutdown(void) efreet_trash_shutdown(void)
{ {
IF_RELEASE(efreet_trash_dir); IF_RELEASE(efreet_trash_dir);
eina_log_domain_unregister(_efreet_trash_log_dom);
} }
/** /**
@ -107,13 +122,13 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
if (!force_delete) return -1; if (!force_delete) return -1;
if (!ecore_file_recursive_rm(uri->path)) if (!ecore_file_recursive_rm(uri->path))
{ {
printf("EFREET TRASH ERROR: Can't delete file.\n"); ERR("EFREET TRASH ERROR: Can't delete file.");
return 0; return 0;
} }
} }
else else
{ {
printf("EFREET TRASH ERROR: Can't move file to trash.\n"); ERR("EFREET TRASH ERROR: Can't move file to trash.");
return 0; return 0;
} }
} }
@ -140,7 +155,7 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
} }
else else
{ {
printf("EFREET TRASH ERROR: Can't create trash info file.\n"); ERR("EFREET TRASH ERROR: Can't create trash info file.");
return 0; return 0;
} }

View File

@ -63,6 +63,14 @@ struct Efreet_Util_Desktop
int priority; int priority;
}; };
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_utils_log_dom
static int _efreet_utils_log_dom = -1;
static char *efreet_util_path_in_default(const char *section, const char *path); static char *efreet_util_path_in_default(const char *section, const char *path);
static int efreet_util_cache_fill(void *data); static int efreet_util_cache_fill(void *data);
@ -116,7 +124,12 @@ efreet_util_init(void)
Eina_List *dirs; Eina_List *dirs;
if (init++) return init; if (init++) return init;
_efreet_utils_log_dom = eina_log_domain_register("Efreet_util",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_utils_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for efreet_util");
return 0;
}
if (!EFREET_EVENT_DESKTOP_LIST_CHANGE) if (!EFREET_EVENT_DESKTOP_LIST_CHANGE)
EFREET_EVENT_DESKTOP_LIST_CHANGE = ecore_event_type_new(); EFREET_EVENT_DESKTOP_LIST_CHANGE = ecore_event_type_new();
if (!EFREET_EVENT_DESKTOP_CHANGE) if (!EFREET_EVENT_DESKTOP_CHANGE)
@ -157,7 +170,7 @@ efreet_util_shutdown(void)
Efreet_Cache_Fill_Dir *dir; Efreet_Cache_Fill_Dir *dir;
if (--init) return init; if (--init) return init;
if (idler) if (idler)
{ {
ecore_idler_del(idler); ecore_idler_del(idler);
@ -185,7 +198,7 @@ efreet_util_shutdown(void)
} }
IF_FREE_HASH(desktops_by_category); IF_FREE_HASH(desktops_by_category);
eina_log_domain_unregister(_efreet_utils_log_dom);
return init; return init;
} }
@ -539,7 +552,7 @@ efreet_util_desktop_category_list(const char *category)
static Eina_Bool static Eina_Bool
dump(Eina_Hash *hash, const char *key, void *value, __UNUSED__ void *data) dump(Eina_Hash *hash, const char *key, void *value, __UNUSED__ void *data)
{ {
printf("%s -> %p\n", (char *)key, value); INF("%s -> %p", (char *)key, value);
} }
#endif #endif
@ -580,7 +593,7 @@ efreet_util_cache_fill(__UNUSED__ void *data)
#if 0 #if 0
eina_hash_foreach(desktop_by_file_id, dump, NULL); eina_hash_foreach(desktop_by_file_id, dump, NULL);
eina_hash_foreach(file_id_by_desktop_path, dump, NULL); eina_hash_foreach(file_id_by_desktop_path, dump, NULL);
printf("%d\n", eina_hash_population(desktop_by_file_id)); DBG("%d", eina_hash_population(desktop_by_file_id));
#endif #endif
efreet_cache_clear(); efreet_cache_clear();
ecore_event_add(EFREET_EVENT_DESKTOP_LIST_CHANGE, NULL, NULL, NULL); ecore_event_add(EFREET_EVENT_DESKTOP_LIST_CHANGE, NULL, NULL, NULL);

View File

@ -38,6 +38,15 @@ static void efreet_xml_comment_skip(char **data, int *size);
static int error = 0; static int error = 0;
static int init = 0; static int init = 0;
/* define macros and variable for using the eina logging system */
#ifdef EFREET_MODULE_LOG_DOM
#undef EFREET_MODULE_LOG_DOM
#endif
#define EFREET_MODULE_LOG_DOM _efreet_xml_log_dom
static int _efreet_xml_log_dom = -1;
/** /**
* @internal * @internal
* @return Returns > 0 on success or 0 on failure * @return Returns > 0 on success or 0 on failure
@ -48,6 +57,12 @@ efreet_xml_init(void)
{ {
if (init++) return init; if (init++) return init;
if (!eina_init()) return --init; if (!eina_init()) return --init;
_efreet_xml_log_dom = eina_log_domain_register("Efreet_xml",EFREET_DEFAULT_LOG_COLOR);
if(_efreet_xml_log_dom < 0)
{
ERROR("Efreet: Could not create a log domain for Efreet_xml.");
return 0;
}
return init; return init;
} }
@ -60,6 +75,7 @@ int
efreet_xml_shutdown(void) efreet_xml_shutdown(void)
{ {
if (--init) return init; if (--init) return init;
eina_log_domain_unregister(_efreet_xml_log_dom);
eina_shutdown(); eina_shutdown();
return init; return init;
} }
@ -98,7 +114,7 @@ efreet_xml_new(const char *file)
return xml; return xml;
efreet_error: efreet_error:
fprintf(stderr, "[efreet]: could not parse xml file\n"); ERR("could not parse xml file");
if (data != (void *)-1) munmap(data, size); if (data != (void *)-1) munmap(data, size);
if (fd != -1) close(fd); if (fd != -1) close(fd);
if (xml) efreet_xml_del(xml); if (xml) efreet_xml_del(xml);
@ -184,18 +200,17 @@ efreet_xml_dump(Efreet_Xml *xml, int level)
Efreet_Xml *child; Efreet_Xml *child;
Eina_List *l; Eina_List *l;
printf(">\n"); printf(">");
EINA_LIST_FOREACH(xml->children, l, child) EINA_LIST_FOREACH(xml->children, l, child)
efreet_xml_dump(child, level + 1); efreet_xml_dump(child, level + 1);
for (i = 0; i < level; i++) for (i = 0; i < level; i++)
printf("\t"); printf("\t");
printf("</%s>\n", xml->tag); printf("</%s>", xml->tag);
} }
else if (xml->text) else if (xml->text)
printf(">%s</%s>\n", xml->text, xml->tag); printf(">%s</%s>\n", xml->text, xml->tag);
else else
printf("/>\n"); printf("/>\n");
} }
@ -276,7 +291,7 @@ efreet_xml_tag_parse(char **data, int *size, const char **tag)
if (!start) if (!start)
{ {
fprintf(stderr, "[efreet]: missing start tag\n"); ERR("missing start tag");
error = 1; error = 1;
return 0; return 0;
} }
@ -294,7 +309,7 @@ efreet_xml_tag_parse(char **data, int *size, const char **tag)
if (!end) if (!end)
{ {
fprintf(stderr, "[efreet]: no end of tag\n"); ERR("no end of tag");
error = 1; error = 1;
return 0; return 0;
} }
@ -302,7 +317,7 @@ efreet_xml_tag_parse(char **data, int *size, const char **tag)
buf_size = end - start + 1; buf_size = end - start + 1;
if (buf_size <= 1) if (buf_size <= 1)
{ {
fprintf(stderr, "[efreet]: no tag name\n"); ERR("no tag name");
error = 1; error = 1;
return 0; return 0;
} }
@ -351,7 +366,7 @@ efreet_xml_attributes_parse(char **data, int *size,
buf_size = end - start + 1; buf_size = end - start + 1;
if (buf_size <= 1) if (buf_size <= 1)
{ {
fprintf(stderr, "[efreet]: zero length key\n"); ERR("zero length key");
goto efreet_error; goto efreet_error;
} }
@ -375,7 +390,7 @@ efreet_xml_attributes_parse(char **data, int *size,
if (!start) if (!start)
{ {
fprintf(stderr, "[efreet]: missing value for attribute!\n"); ERR("missing value for attribute!");
goto efreet_error; goto efreet_error;
} }
@ -394,7 +409,7 @@ efreet_xml_attributes_parse(char **data, int *size,
if (!start) if (!start)
{ {
fprintf(stderr, "[efreet]: erroneous value for attribute!\n"); ERR("erroneous value for attribute!");
goto efreet_error; goto efreet_error;
} }
@ -418,14 +433,14 @@ efreet_xml_attributes_parse(char **data, int *size,
if (!end) if (!end)
{ {
fprintf(stderr, "[efreet]: erroneous value for attribute!\n"); ERR("erroneous value for attribute!");
goto efreet_error; goto efreet_error;
} }
buf_size = end - start + 1; buf_size = end - start + 1;
if (buf_size <= 1) if (buf_size <= 1)
{ {
fprintf(stderr, "[efreet]: zero length value\n"); ERR("zero length value");
goto efreet_error; goto efreet_error;
} }
@ -531,7 +546,7 @@ efreet_xml_tag_empty(char **data, int *size)
(*size)--; (*size)--;
(*data)++; (*data)++;
} }
fprintf(stderr, "[efreet]: missing end of tag\n"); ERR("missing end of tag");
error = 1; error = 1;
return 1; return 1;
@ -550,7 +565,7 @@ efreet_xml_tag_close(char **data, int *size, const char *tag)
(*data) += 2; (*data) += 2;
if ((int)strlen(tag) > *size) if ((int)strlen(tag) > *size)
{ {
fprintf(stderr, "[efreet]: wrong end tag\n"); ERR("wrong end tag");
error = 1; error = 1;
return 1; return 1;
} }
@ -566,7 +581,7 @@ efreet_xml_tag_close(char **data, int *size, const char *tag)
if (*tag) if (*tag)
{ {
fprintf(stderr, "[efreet]: wrong end tag\n"); ERR("wrong end tag");
error = 1; error = 1;
return 1; return 1;
} }