eina: fix eina_log with journald.

Summary:
Nothing was printed to journald before because sd_journal_send_with_location
expects file and line to be of the NAME=VALUE form.

Change-Id: I382b82b665558fddebae61b7d0a8d4de87638511
Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@globallogic.com>

Reviewers: kuri, cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1865

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Vasyl Vavrychuk 2015-01-13 16:18:20 +01:00 committed by Cedric BAIL
parent 615456aae8
commit b613404452
1 changed files with 27 additions and 11 deletions

View File

@ -1927,28 +1927,41 @@ eina_log_print_cb_journald(const Eina_Log_Domain *d,
va_list args)
{
#ifdef HAVE_SYSTEMD
char buf[12];
char *tmp;
char *file_prefixed = NULL;
char *line_str = NULL;
char *message = NULL;
Eina_Thread cur;
int r;
r = vasprintf(&tmp, fmt, args);
r = asprintf(&file_prefixed, "CODE_FILE=%s", file);
if (r == -1)
{
fputs("ERR: eina_log_print_cb_journald() vasprintf failed\n", stderr);
return;
fputs("ERR: eina_log_print_cb_journald() asprintf failed\n", stderr);
goto finish;
}
eina_convert_itoa(line, buf);
r = asprintf(&line_str, "CODE_LINE=%d", line);
if (r == -1)
{
fputs("ERR: eina_log_print_cb_journald() asprintf failed\n", stderr);
goto finish;
}
r = vasprintf(&message, fmt, args);
if (r == -1)
{
fputs("ERR: eina_log_print_cb_journald() vasprintf failed\n", stderr);
goto finish;
}
cur = SELF();
#ifdef EINA_LOG_BACKTRACE
if (EINA_LIKELY(level >= _backtrace_level))
#endif
sd_journal_send_with_location(file, buf, fnc,
sd_journal_send_with_location(file_prefixed, line_str, fnc,
"PRIORITY=%i", level,
"MESSAGE=%s", tmp,
"MESSAGE=%s", message,
"EFL_DOMAIN=%s", d->domain_str,
"THREAD=%lu", cur,
NULL);
@ -1971,9 +1984,9 @@ eina_log_print_cb_journald(const Eina_Log_Domain *d,
else
eina_strbuf_append_printf(bts, "[%s], ", strings[i]);
sd_journal_send_with_location(file, buf, fnc,
sd_journal_send_with_location(file_prefixed, line_str, fnc,
"PRIORITY=%i", level,
"MESSAGE=%s", tmp,
"MESSAGE=%s", message,
"EFL_DOMAIN=%s", d->domain_str,
"THREAD=%lu", cur,
"BACKTRACE=%s",
@ -1984,7 +1997,10 @@ eina_log_print_cb_journald(const Eina_Log_Domain *d,
}
#endif
free(tmp);
finish:
free(file_prefixed);
free(line_str);
free(message);
#else
eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, data, args);