eina_log: CONVENTION BREAK!!!! automatically adds \n
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 3 Sep 2009 01:39:45 +0000 (01:39 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 3 Sep 2009 01:39:45 +0000 (01:39 +0000)
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.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@42200 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_log.c
src/lib/eina_module.c

index 11a1e7e..00d4489 100644 (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.
index 9207799..e7699a4 100644 (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);