Commit Graph

17105 Commits

Author SHA1 Message Date
Philip Withnall
2a5d9f8898 Revert "Add a test for expected messages with structured logging"
This reverts commit bc40c7a05c.

We are going to make g_test_expect_message() only work for the old
logging API.

https://bugzilla.gnome.org/show_bug.cgi?id=769486
2016-08-07 08:07:42 +01:00
Philip Withnall
5c3205f2fb 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
2016-08-04 14:33:34 +01:00
Emmanuele Bassi
5ff8579527 Fix debug builds under MSVC
The C spec leaves conditional evaluation inside a macro expansion as
undefined behaviour. This means we cannot use constructs like:

  GOBJECT_IF_DEBUG(OBJECTS, {
    ...
  #ifdef BLAH
    ...
  #endif
    ...});

Because compilers are entirely justified to ignore the conditional, or,
like in the case of MSVC, error out.

https://bugzilla.gnome.org/show_bug.cgi?id=769504
2016-08-04 10:18:46 +01:00
Aurimas Černius
64f6d14d0c Updated Lithuanian translation 2016-08-03 22:07:51 +03:00
Philip Withnall
04bbf9df37 gdatagrambased: Clarify that connection-oriented ≠ stream-based
GDatagramBased allows connection-oriented and connection-less sockets,
but does not allow stream-based sockets (because it’s datagram-based).
So it supports SCTP and UDP, but not TCP.

Clarify that in the documentation, and people sometimes confuse
connection-oriented with stream-based, due to the prevalence of TCP.
2016-08-03 18:46:29 +01:00
Colin Walters
555c5a6376 gvariant: Fix typo in previous commit 2016-08-03 11:34:43 -04:00
Yury Usishchev
1be86b3d18 glib/gvariant.c: Fix NULL pointer check in is_valid_heap_iter
https://bugzilla.gnome.org/show_bug.cgi?id=769245
2016-08-03 11:27:12 -04:00
Matthias Clasen
bc40c7a05c Add a test for expected messages with structured logging
This tests the fix in the previous commit.
2016-08-02 23:16:04 -04:00
Matthias Clasen
df02e8f47c Make g_test_expect_message work for structured logs
This is used in GTK+ tests, and GTK+ has switched to
G_LOG_USE_STRUCTURED, so we need this to keep working.
2016-08-02 23:16:04 -04:00
Daniel Mustieles
1b711d9b4a Updated Spanish translation 2016-08-02 16:46:35 +02:00
Mario Sanchez Prada
fbf72a31b1 Don't enable libmount by default for now
This is causing trouble with flatpaks because the org.gnome.Platform
runtime does not bundle libmount, while the org.gnome.Sdk does it.

As this probably requires a change in the freedesktop.org Yocto base,
we disable this support by default for now as a temporary measure
until it can be properly reviewed by someone who knows those bits
better, probably Alex Larsson.

https://bugzilla.gnome.org/show_bug.cgi?id=769284
2016-07-28 12:24:14 -06:00
Mario Sanchez Prada
ed75b1623d gunixmounts: Ensure that libmount's context gets freed on early returns
Otherwise, it will be leaked in case the relevant table (mtab, fstab)
could not be retrieved for some reason.

https://bugzilla.gnome.org/show_bug.cgi?id=769238
2016-07-28 08:24:57 -06:00
Mario Sanchez Prada
b28c76b0d8 gunixmounts: Do not leak libmount tables in _g_get_unix_mounts()
Use mnt_context_get_mtab instead of using mnt_context_get_table(), since
that's the recommended way of accessing mtab/mountinfo information, and
also because that way the (struct libmnt_table *) will get automatically
deallocated when calling mnt_free_context()

https://bugzilla.gnome.org/show_bug.cgi?id=769238
2016-07-28 08:24:57 -06:00
Chun-wei Fan
7cf037ec16 gmessages.h: Use G_STRFUNC instead of __func__
We have G_STRFUNC which takes care of __func__, which may not be available
depending on compiler, so we ought to make use of it.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
2016-07-28 16:04:02 +08:00
Chun-wei Fan
48317b199b gio/gappinfo.c: Include gtask.h
This avoids warning/error C4013 (aka implicit declaration of ...) as we
need APIs from gtask.h.
2016-07-27 16:06:21 +08:00
Chun-wei Fan
6d6b97aa59 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
2016-07-27 10:45:00 +08:00
Matthias Clasen
c1e8f705dd Add async variant of g_app_info_launch_default_for_uri
This is useful in the portalized case, when the portal may
present an app chooser dialog to the user.

https://bugzilla.gnome.org/show_bug.cgi?id=768752
2016-07-26 16:05:29 -04:00
Mario Sanchez Prada
f885c4dd0d Monitor /proc/self/mountinfo when using libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
97f799b53a Refactor common code into create_unix_mount_point ()
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
44f4309e3b Implemented _g_get_unix_mount_points() based on libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
2051ee7678 Refactor common code into create_unix_mount_entry ()
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
030594777a Implemented _g_get_unix_mounts() based on libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
8d5cf2df10 Use libmount to find the path of the fstab file
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
4f9cddaeb8 Added autotools support for libmount
Check whether libmount is available at configuration time and provide
an option to explicitly enable or disable it, similar to libelf.

https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Matthias Clasen
496c52ec79 Avoid htole64 altogether
GLib ships its own api for this, lets use it.
2016-07-25 12:31:52 -04:00
Matthias Clasen
ad285d9bd2 Handle EINTR when sending logs to the journal
Ray pointed out that we might well get interrupted here,
and should not loose logs due to that.
2016-07-25 10:25:40 -04:00
Matthias Clasen
34cb9c7de1 Explicitly include endian.h
htole64 is defined here.

https://bugzilla.gnome.org/show_bug.cgi?id=769139
2016-07-25 10:15:08 -04:00
Matthias Clasen
a2d5d1f119 Use SOCK_CLOEXEC if available
Ray pointed out that we can avoid the race here.
2016-07-25 09:47:26 -04:00
Thiago Macieira
a5f209bc65 Fall back for overflow-checked arithmetic with Intel compiler
The Intel compiler does not have intrinsics like `__builtin_uadd_overflow`.

https://bugzilla.gnome.org/show_bug.cgi?id=769104
2016-07-23 09:27:52 -04:00
Matthias Clasen
df457c9110 Update logging tests
We now treat the PRIORITY field like other string fields, and
set its length to -1. Adapt the tests for this.
2016-07-22 23:06:52 -04:00
Matthias Clasen
6a07885a98 Drop libsystemd dependency
Talk to the journal ourselves using sendmsg() instead of linking
against libsystemd for sd_journal_sendv(). At the same time, we
can also avoid excessive copying.

The motivation for dropping the dependency is that we can
then use structured logging e.g. in a flatpak sandbox where
libsystemd may not be present in the runtime.

The code here is inspired by similar code in libvirt.
2016-07-22 23:04:51 -04:00
Matthias Clasen
ca775518d8 Add more structured logging tests
In particular, add a test to ensure that passing NULL
as log_domain has no negative consequences.
2016-07-22 15:12:42 -04:00
Matthias Clasen
e7ee56dd1d Make g_log_set_writer_func work more than once
It is fine to document that you shall only call this once,
but for tests, it is important that we can call it multiple
times.
2016-07-22 15:12:42 -04:00
Matthias Clasen
97a38dc586 Fix a small typo 2016-07-22 15:12:42 -04:00
Emilio Pozuelo Monfort
38317cf746 Use a uint64 to unpack a 64 bit value
https://bugzilla.gnome.org/show_bug.cgi?id=769089
2016-07-22 19:20:30 +02:00
Ray Strode
f414cddc1f gmessages: support NULL log domain
It's possible that a project may not define the G_LOG_DOMAIN but
still use g_log functions.  In such cases, we now crash.

This commit fixes that.

https://bugzilla.gnome.org/show_bug.cgi?id=769087
2016-07-22 11:33:14 -04:00
Matthias Clasen
f38845c116 Expand g_log_structured docs a bit
Mention two possible pitfalls that were pointed out by Ray Strode.
2016-07-21 14:52:46 -04:00
Matthias Clasen
d5efa64539 Deal with lack of O_CLOEXEC
Some platforms don't have it. We fall back to fcntl() in other
places, so do it here as well.

https://bugzilla.gnome.org/show_bug.cgi?id=769042
2016-07-21 11:54:14 -04:00
Alberts Muktupāvels
ad669500a6 gobject: add g_autoptr support for GTypeModule
https://bugzilla.gnome.org/show_bug.cgi?id=769033
2016-07-21 17:03:06 +03:00
Krzesimir Nowak
d5a16fbd2d gvariant: Avoid anonymous struct and union members
C++ does not like them for various reasons.

https://bugzilla.gnome.org/show_bug.cgi?id=766370
2016-07-21 14:06:58 +02:00
Daniel P. Berrange
b9934f16b6 gchecksum: annotate when G_CHECKSUM_SHA512 was introduced
Currently the docs for GChecksumType are simpy annotated
with 'Since 2.16' which is when GChecksumType was first
introduced. No mention is made of the fact that the
G_CHECKSUM_SHA512 constant was only added much later
in 2.36.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=769027
2016-07-21 08:03:26 -04:00
Víctor Manuel Jáquez Leal
d311177948 gmessage: Suppress string format literal warning
https://bugzilla.gnome.org/show_bug.cgi?id=769029
2016-07-21 07:12:46 -04:00
Matthias Clasen
e4623800aa 2.49.4 2016-07-20 20:52:48 -04:00
Matthias Clasen
849599671c Update structured logging docs a bit
Remove references to removed macros, add some more links
to standard journal fields.
2016-07-20 20:42:09 -04:00
Matthias Clasen
4643cadc17 Add structured logging to the docs 2016-07-20 20:42:09 -04:00
Matthias Clasen
6554086070 Make gtk-doc handle GLogField
gtk-doc can't deal with typedef struct {...} GLogField, it seems.
2016-07-20 20:42:09 -04:00
Matthias Clasen
f5a8dfb6af Improve journal detection
We can use getpeername() and check if we have a socket that
is in /run/systemd/journal/.
2016-07-20 20:42:09 -04:00
Matthias Clasen
3892034455 Add more tests for g_log_structured 2016-07-20 20:42:09 -04:00
Matthias Clasen
bdcf9e8b4e Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:

g_log_structured (domain, level,
                  key-value pairs...
                  "MESSAGE", format,
                  printf arguments);

This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.

Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-20 20:42:09 -04:00
Matthias Clasen
fec01b630a Use g_log_structured_array in g_logv
We already formatted the message; there is no need to
go through the printf machinery a second time.
2016-07-20 20:42:09 -04:00