gmessages: Don’t require is_journald() call before writer_journald()

g_log_writer_is_journald() works out whether the process’ stderr or
stdout are redirected to journald. While the default writer function
uses this in conjunction with g_log_writer_journald(), that does not
always have to be the case — other writer functions might want to always
write to the journal, and never write to stderr (for example).

Consequently, automatically open the journal socket in
writer_journald(), rather than is_journald().

https://bugzilla.gnome.org/show_bug.cgi?id=769507
This commit is contained in:
Philip Withnall 2016-08-04 10:35:27 +01:00
parent 5ff8579527
commit 5c3205f2fb

View File

@ -1687,9 +1687,6 @@ g_log_writer_is_journald (gint output_fd)
fd_is_journal = g_str_has_prefix (((struct sockaddr_un *)&addr)->sun_path,
"/run/systemd/journal/");
if (fd_is_journal)
open_journal ();
g_once_init_leave (&initialized, TRUE);
}
@ -1822,6 +1819,9 @@ journal_sendv (struct iovec *iov,
struct cmsghdr *cmsg;
char path[] = "/dev/shm/journal.XXXXXX";
if (journal_fd < 0)
open_journal ();
if (journal_fd < 0)
return -1;