mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-02 05:43:07 +02:00
gmessages.c: Fix build on non-Linux
journald is a part of systemd which is Linux-only at this time, so only compile the journald items on Linux only, and just return FALSE for g_log_writer_is_journald() and G_LOG_WRITER_UNHANDLED for g_log_writer_journald() on non-Linux. https://bugzilla.gnome.org/show_bug.cgi?id=744456
This commit is contained in:
parent
c1e8f705dd
commit
6d6b97aa59
@ -101,11 +101,14 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glib-init.h"
|
#include "glib-init.h"
|
||||||
#include "galloca.h"
|
#include "galloca.h"
|
||||||
@ -1618,6 +1621,7 @@ g_log_writer_supports_color (gint output_fd)
|
|||||||
return isatty (output_fd);
|
return isatty (output_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
static int journal_fd = -1;
|
static int journal_fd = -1;
|
||||||
|
|
||||||
#ifndef SOCK_CLOEXEC
|
#ifndef SOCK_CLOEXEC
|
||||||
@ -1640,6 +1644,7 @@ open_journal (void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_log_writer_is_journald:
|
* g_log_writer_is_journald:
|
||||||
@ -1655,6 +1660,7 @@ open_journal (void)
|
|||||||
gboolean
|
gboolean
|
||||||
g_log_writer_is_journald (gint output_fd)
|
g_log_writer_is_journald (gint output_fd)
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
/* FIXME: Use the new journal API for detecting whether we’re writing to the
|
/* FIXME: Use the new journal API for detecting whether we’re writing to the
|
||||||
* journal. See: https://github.com/systemd/systemd/issues/2473
|
* journal. See: https://github.com/systemd/systemd/issues/2473
|
||||||
*/
|
*/
|
||||||
@ -1679,6 +1685,9 @@ g_log_writer_is_journald (gint output_fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fd_is_journal;
|
return fd_is_journal;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void escape_string (GString *string);
|
static void escape_string (GString *string);
|
||||||
@ -1789,6 +1798,7 @@ g_log_writer_format_fields (GLogLevelFlags log_level,
|
|||||||
return g_string_free (gstring, FALSE);
|
return g_string_free (gstring, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
static int
|
static int
|
||||||
journal_sendv (struct iovec *iov,
|
journal_sendv (struct iovec *iov,
|
||||||
gsize iovlen)
|
gsize iovlen)
|
||||||
@ -1869,6 +1879,7 @@ retry2:
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_log_writer_journald:
|
* g_log_writer_journald:
|
||||||
@ -1898,6 +1909,7 @@ g_log_writer_journald (GLogLevelFlags log_level,
|
|||||||
gsize n_fields,
|
gsize n_fields,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
const char equals = '=';
|
const char equals = '=';
|
||||||
const char newline = '\n';
|
const char newline = '\n';
|
||||||
gsize i, k;
|
gsize i, k;
|
||||||
@ -1975,6 +1987,9 @@ g_log_writer_journald (GLogLevelFlags log_level,
|
|||||||
retval = journal_sendv (iov, v - iov);
|
retval = journal_sendv (iov, v - iov);
|
||||||
|
|
||||||
return retval == 0 ? G_LOG_WRITER_HANDLED : G_LOG_WRITER_UNHANDLED;
|
return retval == 0 ? G_LOG_WRITER_HANDLED : G_LOG_WRITER_UNHANDLED;
|
||||||
|
#else
|
||||||
|
return G_LOG_WRITER_UNHANDLED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user