eina_log: CONVENTION BREAK!!!! automatically adds \n

Automatically add \n to messages. Since we use that prefix, there is
no use to allow messages without \n, it would look a mess.

Some logging systems may not require the trailing newline, for example
logging to xml or syslog, for those you don't need to ignore this char
if present.

Yes, this breaks convention, but better now than latter. And the
results are not so bad.



SVN revision: 42200
This commit is contained in:
Gustavo Sverzut Barbieri 2009-09-03 01:39:45 +00:00
parent 8024360138
commit cee03dcb3c
2 changed files with 18 additions and 14 deletions

View File

@ -1001,6 +1001,7 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level,
}
end:
vfprintf(stderr, fmt, args);
putc('\n', stderr);
}
/**
@ -1079,6 +1080,7 @@ eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level,
}
end:
vprintf(fmt, args);
putchar('\n');
}
/**
@ -1110,6 +1112,7 @@ eina_log_print_cb_file(const Eina_Log_Domain *d, __UNUSED__ Eina_Log_Level level
fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
end:
vfprintf(f, fmt, args);
putc('\n', f);
}
static inline void
@ -1159,7 +1162,8 @@ eina_log_print_unlocked(int domain, Eina_Log_Level level, const char *file, cons
* @param file filename that originated the call, must @b not be @c NULL.
* @param fnc function that originated the call, must @b not be @c NULL.
* @param line originating line in @a file.
* @param fmt printf-like format to use.
* @param fmt printf-like format to use. Should not provide trailing
* '\n' as it is automatically included.
*
* @note MT: this function may be called from different threads if
* eina_log_threads_enable() was called before.

View File

@ -219,14 +219,14 @@ eina_module_init(void)
("eina_module", EINA_LOG_COLOR_DEFAULT);
if (EINA_MODULE_LOG_DOM < 0)
{
EINA_LOG_ERR("Could not register log domain: eina_module\n");
EINA_LOG_ERR("Could not register log domain: eina_module");
eina_log_shutdown();
return 0;
}
if (!eina_error_init())
{
ERR("Could not initialize eina error module.\n");
ERR("Could not initialize eina error module.");
eina_log_shutdown();
return 0;
}
@ -301,13 +301,13 @@ EAPI Eina_Module *eina_module_new(const char *file)
m = malloc(sizeof(Eina_Module) + len + 1);
if (!m) {
ERR("could not malloc(%lu)\n", sizeof(Eina_Module) + len + 1);
ERR("could not malloc(%lu)", sizeof(Eina_Module) + len + 1);
return NULL;
}
memcpy((char *)m->file, file, len + 1);
m->ref = 0;
m->handle = NULL;
DBG("m=%p, file=%s\n", m, file);
DBG("m=%p, file=%s", m, file);
return m;
}
@ -327,7 +327,7 @@ EAPI Eina_Bool eina_module_free(Eina_Module *m)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
DBG("m=%p, handle=%p, file=%s, refs=%d\n", m, m->handle, m->file, m->ref);
DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
if (m->handle)
{
@ -365,14 +365,14 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
DBG("m=%p, handle=%p, file=%s, refs=%d\n", m, m->handle, m->file, m->ref);
DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
if (m->handle) goto loaded;
dl_handle = dlopen(m->file, RTLD_NOW);
if (!dl_handle)
{
WRN("could not dlopen(\"%s\", RTLD_NOW): %s\n", m->file, dlerror());
WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
eina_error_set(EINA_ERROR_WRONG_MODULE);
return EINA_FALSE;
}
@ -383,7 +383,7 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
if ((*initcall)() == EINA_TRUE)
goto ok;
WRN("could not find eina's entry symbol %s inside module %s\n",
WRN("could not find eina's entry symbol %s inside module %s",
EINA_MODULE_SYMBOL_INIT, m->file);
eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
dlclose(dl_handle);
@ -418,7 +418,7 @@ EAPI Eina_Bool eina_module_unload(Eina_Module *m)
Eina_Module_Shutdown *shut;
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
DBG("m=%p, handle=%p, file=%s, refs=%d\n", m, m->handle, m->file, m->ref);
DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
m->ref--;
if (!m->ref)
@ -428,7 +428,7 @@ EAPI Eina_Bool eina_module_unload(Eina_Module *m)
(*shut)();
dlclose(m->handle);
m->handle = NULL;
DBG("unloaded module %s\n", m->file);
DBG("unloaded module %s", m->file);
return EINA_TRUE;
}
return EINA_FALSE;
@ -577,7 +577,7 @@ EAPI void eina_module_list_load(Eina_Array *array)
unsigned int i;
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u\n", array, array->count);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
eina_module_load(m);
}
@ -593,7 +593,7 @@ EAPI void eina_module_list_unload(Eina_Array *array)
unsigned int i;
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u\n", array, array->count);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
eina_module_unload(m);
}
@ -609,7 +609,7 @@ EAPI void eina_module_list_flush(Eina_Array *array)
unsigned int i;
EINA_SAFETY_ON_NULL_RETURN(array);
DBG("array %p, count %u\n", array, array->count);
DBG("array %p, count %u", array, array->count);
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
eina_module_free(m);