tasn pushed a commit to branch master. http://git.enlightenment.org/apps/ecrire.git/commit/?id=fad91b5badf7b433601878f774dd66f8573c6231
commit fad91b5badf7b433601878f774dd66f8573c6231 Author: Srivardhan Hebbar <[email protected]> Date: Wed Sep 10 14:58:35 2014 +0100 Add a log as was in the Fixme in cfg.c Summary: Was going through the ecraire to understand so that I can contribute. Saw the Fixme and added this log. Signed-off-by: Srivardhan Hebbar <[email protected]> Reviewers: tasn Differential Revision: https://phab.enlightenment.org/D1423 --- src/bin/cfg.c | 4 ++-- src/bin/file_utils.c | 6 ++++-- src/bin/main.c | 27 +++++++++++++++++++++++---- src/bin/mess_header.h | 9 +++++++++ 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/bin/cfg.c b/src/bin/cfg.c index a4c6dd1..1c2204e 100644 --- a/src/bin/cfg.c +++ b/src/bin/cfg.c @@ -97,7 +97,7 @@ ecrire_cfg_load(void) ef = eet_open(config_file, EET_FILE_MODE_READ); if (!ef) { - /* FIXME Info message? create new config? */ + INF("Failed to read the config file. Creating a new one."); goto end; } @@ -127,7 +127,7 @@ ecrire_cfg_save(void) ef = eet_open(config_file, EET_FILE_MODE_WRITE); if (!ef) { - EINA_LOG_ERR("could not open '%s' for writing.", config_file); + ERR("could not open '%s' for writing.", config_file); return EINA_FALSE; } diff --git a/src/bin/file_utils.c b/src/bin/file_utils.c index ef60669..cbf05e1 100644 --- a/src/bin/file_utils.c +++ b/src/bin/file_utils.c @@ -3,6 +3,8 @@ #include <stdio.h> #include <string.h> +#include "mess_header.h" + static char * _buf_append(char *buf, const char *str, int *len, int *alloc) { @@ -66,14 +68,14 @@ _save_markup_utf8(const char *file, const char *text) f = fopen(file, "wb"); if (!f) { - EINA_LOG_ERR("could not open '%s' for writing.", file); + ERR("could not open '%s' for writing.", file); return EINA_FALSE; } if (text) { if (fputs(text, f) == EOF) { - EINA_LOG_ERR("Error in writing to '%s'.", file); + ERR("Error in writing to '%s'.", file); return EINA_FALSE; } } diff --git a/src/bin/main.c b/src/bin/main.c index c6de252..26cab09 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -22,6 +22,9 @@ static Ecrire_Entry *main_ec_ent; static void print_usage(const char *bin); static void editor_font_set(Ecrire_Entry *ent, const char *font, int font_size); +/* specific log domain to help debug only ecrire */ +int _ecrire_log_dom = -1; + static void _init_entry(Ecrire_Entry *ent) { @@ -213,7 +216,7 @@ _undo_stack_add(Ecrire_Entry *ent, Elm_Entry_Change_Info *_info) static void _undo_redo_do(Ecrire_Entry *ent, Elm_Entry_Change_Info *inf, Eina_Bool undo) { - EINA_LOG_DBG("%s: %s", (undo) ? "Undo" : "Redo", + DBG("%s: %s", (undo) ? "Undo" : "Redo", inf->change.insert.content); if ((inf->insert && undo) || (!inf->insert && !undo)) @@ -594,6 +597,19 @@ main(int argc, char *argv[]) opterr = 0; + if (!eina_init()) + { + printf("Failed to initialize Eina_log module\n"); + return EXIT_FAILURE; + } + + _ecrire_log_dom = eina_log_domain_register("ecrire", ECRIRE_DEFAULT_LOG_COLOR); + if (_ecrire_log_dom < 0) + { + EINA_LOG_ERR("Unable to create a log domain."); + exit(-1); + } + while ((c = getopt (argc, argv, "")) != -1) { switch (c) @@ -602,12 +618,12 @@ main(int argc, char *argv[]) print_usage(argv[0]); if (isprint (optopt)) { - EINA_LOG_ERR("Unknown option or requires an argument `-%c'.", + ERR("Unknown option or requires an argument `-%c'.", optopt); } else { - EINA_LOG_ERR("Unknown option character `\\x%x'.", optopt); + ERR("Unknown option character `\\x%x'.", optopt); } return 1; break; @@ -636,7 +652,7 @@ main(int argc, char *argv[]) main_ec_ent->filename = eina_stringshare_add(argv[optind]); } - EINA_LOG_DBG("Opening filename: '%s'", main_ec_ent->filename); + DBG("Opening filename: '%s'", main_ec_ent->filename); main_ec_ent->win = elm_win_add(NULL, "editor", ELM_WIN_BASIC); elm_win_autodel_set(main_ec_ent->win, EINA_FALSE); @@ -746,6 +762,9 @@ main(int argc, char *argv[]) ecrire_cfg_shutdown(); elm_shutdown(); + eina_log_domain_unregister(_ecrire_log_dom); + _ecrire_log_dom = -1; + eina_shutdown(); return 0; } diff --git a/src/bin/mess_header.h b/src/bin/mess_header.h index 355e67f..5976f4d 100644 --- a/src/bin/mess_header.h +++ b/src/bin/mess_header.h @@ -3,6 +3,15 @@ #include <Evas.h> +extern int _ecrire_log_dom; +#define ECRIRE_DEFAULT_LOG_COLOR EINA_COLOR_CYAN + +#define CRI(...) EINA_LOG_DOM_CRIT(_ecrire_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_ecrire_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_ecrire_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_ecrire_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_ecrire_log_dom, __VA_ARGS__) + struct _Ecrire_Entry { Evas_Object *entry; Evas_Object *win; --
