forked from enlightenment/efl
eolian: use new error logging for all recoverable errors
This commit is contained in:
parent
008d990181
commit
a1ae5cd918
|
@ -95,8 +95,8 @@ eolian_class_function_by_name_get(const Eolian_Class *cl, const char *func_name,
|
|||
}
|
||||
}
|
||||
|
||||
_eolian_log("function '%s' not found in class '%s'", func_name,
|
||||
eolian_object_short_name_get(&cl->base));
|
||||
eolian_state_log(cl->base.unit->state, "function '%s' not found in class '%s'",
|
||||
func_name, eolian_object_short_name_get(&cl->base));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
static Eina_Bool
|
||||
node_error(const Eolian_Object *obj, const char *msg)
|
||||
{
|
||||
_eolian_log_line(obj->file, obj->line, obj->column, "%s", msg);
|
||||
eolian_state_log_obj(obj->unit->state, obj, "%s", msg);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ _validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, const Eolian_Obj
|
|||
if (eolian_doc_token_ref_resolve(&tok, src, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN)
|
||||
{
|
||||
char *refn = eolian_doc_token_text_get(&tok);
|
||||
_eolian_log_line(info->file, info->line, info->column,
|
||||
"failed validating reference '%s'", refn);
|
||||
eolian_state_log_obj(info->unit->state, info,
|
||||
"failed validating reference '%s'", refn);
|
||||
free(refn);
|
||||
ret = EINA_FALSE;
|
||||
break;
|
||||
|
@ -116,7 +116,7 @@ _ef_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
|||
static Eina_Bool
|
||||
_obj_error(const Eolian_Object *o, const char *msg)
|
||||
{
|
||||
_eolian_log_line(o->file, o->line, o->column, "%s", msg);
|
||||
eolian_state_log_obj(o->unit->state, o, "%s", msg);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ _get_impl_class(const Eolian_Class *cl, const char *cln)
|
|||
}
|
||||
|
||||
#define _eo_parser_log(_base, ...) \
|
||||
_eolian_log_line((_base)->file, (_base)->line, (_base)->column, __VA_ARGS__)
|
||||
eolian_state_log_obj((_base)->unit->state, (_base), __VA_ARGS__)
|
||||
|
||||
static Eina_Bool
|
||||
_db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
|
||||
|
|
|
@ -108,8 +108,13 @@ throw(Eo_Lexer *ls, const char *fmt, ...)
|
|||
for (i = 0; i < ls->column; ++i)
|
||||
eina_strbuf_append_char(buf, ' ');
|
||||
eina_strbuf_append(buf, "^\n");
|
||||
_eolian_log_line(ls->source, ls->line_number, ls->column,
|
||||
"%s", eina_strbuf_string_get(buf));
|
||||
Eolian_Object tmp;
|
||||
memset(&tmp, 0, sizeof(Eolian_Object));
|
||||
tmp.unit = ls->unit;
|
||||
tmp.file = ls->source;
|
||||
tmp.line = ls->line_number;
|
||||
tmp.column = ls->column;
|
||||
eolian_state_log_obj(ls->state, &tmp, "%s", eina_strbuf_string_get(buf));
|
||||
eina_strbuf_free(buf);
|
||||
longjmp(ls->err_jmp, EINA_TRUE);
|
||||
}
|
||||
|
@ -1020,9 +1025,9 @@ _node_free(Eolian_Object *obj)
|
|||
/* for when we have a proper node allocator and collect on shutdown */
|
||||
if (obj->refcount > 1)
|
||||
{
|
||||
_eolian_log("node %p (type %d, name %s at %s:%d:%d)"
|
||||
" dangling ref (count: %d)", obj, obj->type, obj->name,
|
||||
obj->file, obj->line, obj->column, obj->refcount);
|
||||
eolian_state_log(obj->state, "node %p (type %d, name %s at %s:%d:%d)"
|
||||
" dangling ref (count: %d)", obj, obj->type, obj->name,
|
||||
obj->file, obj->line, obj->column, obj->refcount);
|
||||
}
|
||||
#endif
|
||||
switch (obj->type)
|
||||
|
@ -1055,7 +1060,7 @@ eo_lexer_set_input(Eo_Lexer *ls, Eolian_State *state, const char *source)
|
|||
Eina_File *f = eina_file_open(source, EINA_FALSE);
|
||||
if (!f)
|
||||
{
|
||||
_eolian_log("%s", strerror(errno));
|
||||
eolian_state_log(ls->state, "%s", strerror(errno));
|
||||
longjmp(ls->err_jmp, EINA_TRUE);
|
||||
}
|
||||
ls->lookahead.token = -1;
|
||||
|
@ -1290,6 +1295,7 @@ eo_lexer_context_push(Eo_Lexer *ls)
|
|||
Lexer_Ctx *ctx = malloc(sizeof(Lexer_Ctx));
|
||||
if (!ctx)
|
||||
{
|
||||
/* FIXME unrecoverable */
|
||||
_eolian_log("out of memory pushing context");
|
||||
longjmp(ls->err_jmp, EINA_TRUE);
|
||||
}
|
||||
|
|
|
@ -1071,10 +1071,16 @@ parse_accessor:
|
|||
{
|
||||
if (getenv("EOLIAN_PROPERTY_DOC_WARN"))
|
||||
{
|
||||
_eolian_log_line(prop->base.file, line, col,
|
||||
"%s doc without property doc for '%s.%s'",
|
||||
is_get ? "getter" : "setter",
|
||||
ls->klass->base.name, prop->base.name);
|
||||
Eolian_Object tmp;
|
||||
memset(&tmp, 0, sizeof(Eolian_Object));
|
||||
tmp.file = prop->base.file;
|
||||
tmp.line = line;
|
||||
tmp.column = col;
|
||||
tmp.unit = ls->unit;
|
||||
eolian_state_log_obj(ls->state, &tmp,
|
||||
"%s doc without property doc for '%s.%s'",
|
||||
is_get ? "getter" : "setter",
|
||||
ls->klass->base.name, prop->base.name);
|
||||
}
|
||||
}
|
||||
if (is_get)
|
||||
|
@ -2210,7 +2216,8 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
|
|||
Eo_Lexer *ls = eo_lexer_new(parent->state, filename);
|
||||
if (!ls)
|
||||
{
|
||||
_eolian_log("unable to create lexer for file '%s'", filename);
|
||||
eolian_state_log(parent->state, "unable to create lexer for file '%s'",
|
||||
filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -2226,7 +2233,7 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
|
|||
Eolian_Class *cl;
|
||||
if (!(cl = ls->klass))
|
||||
{
|
||||
_eolian_log("eolian: no class for file '%s'", filename);
|
||||
eolian_state_log(ls->state, "no class for file '%s'", filename);
|
||||
goto error;
|
||||
}
|
||||
ls->klass = NULL;
|
||||
|
|
|
@ -580,7 +580,10 @@ _default_panic_cb(const Eolian_State *state EINA_UNUSED, const char *msg)
|
|||
static void
|
||||
_default_error_cb(const Eolian_Object *obj, const char *msg, void *data EINA_UNUSED)
|
||||
{
|
||||
_eolian_log_line(obj->file, obj->line, obj->column, msg);
|
||||
if (obj)
|
||||
_eolian_log_line(obj->file, obj->line, obj->column, msg);
|
||||
else
|
||||
_eolian_log(msg);
|
||||
}
|
||||
|
||||
EAPI Eolian_State *
|
||||
|
@ -649,7 +652,7 @@ EAPI Eolian_Panic_Cb
|
|||
eolian_state_panic_cb_set(Eolian_State *state, Eolian_Panic_Cb cb)
|
||||
{
|
||||
Eolian_Panic_Cb old_cb = state->panic;
|
||||
state->panic = cb;
|
||||
state->panic = cb ? cb : _default_panic_cb;
|
||||
return old_cb;
|
||||
}
|
||||
|
||||
|
@ -657,7 +660,7 @@ EAPI Eolian_Error_Cb
|
|||
eolian_state_error_cb_set(Eolian_State *state, Eolian_Error_Cb cb)
|
||||
{
|
||||
Eolian_Error_Cb old_cb = state->error;
|
||||
state->error = cb;
|
||||
state->error = cb ? cb : _default_error_cb;
|
||||
return old_cb;
|
||||
}
|
||||
|
||||
|
@ -754,7 +757,9 @@ _eolian_file_parse_nodep(Eolian_Unit *parent, const char *filepath)
|
|||
is_eo = eina_str_has_suffix(filepath, EO_SUFFIX);
|
||||
if (!is_eo && !eina_str_has_suffix(filepath, EOT_SUFFIX))
|
||||
{
|
||||
_eolian_log("file '%s' doesn't have a correct extension", filepath);
|
||||
eolian_state_log(parent->state,
|
||||
"file '%s' doesn't have a correct extension",
|
||||
filepath);
|
||||
return NULL;
|
||||
}
|
||||
if (!(eopath = eina_hash_find(is_eo ? parent->state->filenames_eo : parent->state->filenames_eot, filepath)))
|
||||
|
|
|
@ -110,6 +110,41 @@ eolian_object_add(Eolian_Object *obj, Eina_Stringshare *name, Eina_Hash *hash)
|
|||
eolian_object_add(&obj->base, name, tunit->memb); \
|
||||
}
|
||||
|
||||
static inline void eolian_state_vlog(const Eolian_State *state, const Eolian_Object *obj, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 3);
|
||||
static inline void eolian_state_log(const Eolian_State *state, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
|
||||
static inline void eolian_state_log_obj(const Eolian_State *state, const Eolian_Object *obj, const char *fmt, ...) EINA_ARG_NONNULL(1, 2, 3) EINA_PRINTF(3, 4);
|
||||
|
||||
|
||||
static inline void
|
||||
eolian_state_vlog(const Eolian_State *state, const Eolian_Object *obj,
|
||||
const char *fmt, va_list args)
|
||||
{
|
||||
Eina_Strbuf *sb = eina_strbuf_new();
|
||||
eina_strbuf_append_vprintf(sb, fmt, args);
|
||||
state->error(obj, eina_strbuf_string_get(sb), state->error_data);
|
||||
eina_strbuf_free(sb);
|
||||
}
|
||||
|
||||
static inline void
|
||||
eolian_state_log(const Eolian_State *state, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
eolian_state_vlog(state, NULL, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline void
|
||||
eolian_state_log_obj(const Eolian_State *state, const Eolian_Object *obj,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
eolian_state_vlog(state, obj, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
struct _Eolian_Documentation
|
||||
{
|
||||
Eolian_Object base;
|
||||
|
|
|
@ -5,32 +5,23 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
static inline void _eolian_log_line(const char *file, int line, int column, const char *fmt, ...) EINA_ARG_NONNULL(1, 4) EINA_PRINTF(4, 5);
|
||||
static inline void _eolian_log_line(const char *file, int line, int column, const char *str) EINA_ARG_NONNULL(1, 4);
|
||||
static inline void _eolian_log(const char *fmt, ...) EINA_ARG_NONNULL(1) EINA_PRINTF(1, 2);
|
||||
|
||||
static inline void
|
||||
_eolian_log_line(const char *file, int line, int column, const char *fmt, ...)
|
||||
_eolian_log_line(const char *file, int line, int column, const char *str)
|
||||
{
|
||||
Eina_Strbuf *sb = eina_strbuf_new();
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
eina_strbuf_append_vprintf(sb, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (!eina_log_color_disable_get())
|
||||
{
|
||||
fprintf(stderr, EINA_COLOR_RED "eolian" EINA_COLOR_RESET ": "
|
||||
EINA_COLOR_WHITE "%s" EINA_COLOR_RESET ":%d:%d: "
|
||||
EINA_COLOR_ORANGE "%s\n" EINA_COLOR_RESET,
|
||||
file, line, column, eina_strbuf_string_get(sb));
|
||||
file, line, column, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "eolian: %s:%d:%d: %s\n", file, line, column,
|
||||
eina_strbuf_string_get(sb));
|
||||
fprintf(stderr, "eolian: %s:%d:%d: %s\n", file, line, column, str);
|
||||
}
|
||||
eina_strbuf_free(sb);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
Loading…
Reference in New Issue