Commit Graph

16642 Commits

Author SHA1 Message Date
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
Matthias Clasen
0d0ba82cec Allow using g_log_structured instead of g_log
Look for a macro G_LOG_USE_STRUCTURED, and if it is defined, use
g_log_structured instead of g_log when defining g_warning and friends.
This avoids the extra complication of going through g_logv _and_
g_log_structured to get a message logged; it also lets us pass
the code-related fields.

We don't do this unconditionally (yet), since some users might
rely on the more fine-grained fatality support in g_logv. It has
also been proven problematic in the past to inject a dependency
on bleeding-edge API via a widely-used macro.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
2016-07-20 20:42:09 -04:00
Matthias Clasen
db0bf5bbf1 proxy resolver portal: Fix the async api 2016-07-20 20:42:09 -04:00
Emilio Pozuelo Monfort
5cede43df6 Ship gio.xml in tarballs
Fixes the documentation build.

https://bugzilla.gnome.org/show_bug.cgi?id=768936
2016-07-20 10:54:52 +02:00
Dan Winship
6de5595570 Fix gio/tests/socket-listener
g_socket_listener_add_address() is synchronous; all of the events will
have been emitted before it returns and it doesn't queue any sources.
The test was unintentionally depending on the fact that
g_main_context_iterate(NULL, TRUE) would return anyway (at least the
first time it was called), but that's no longer true after e4ee307.

https://bugzilla.gnome.org/show_bug.cgi?id=768968
2016-07-19 17:22:07 -04:00
Emmanuele Bassi
7e40228cae Update the ignore file for GIO 2016-07-19 14:18:49 +01:00
Rico Tzschichholz
c67bd6cc54 gmessages: Fix G_GNUC_PRINTF mark for g_log_structured
GCC fails to build because of the trailing arguments, not part of the
format:

../../glib/gmessages.c: In function 'g_log_default_handler':
../../glib/gmessages.c:2385:21: error: too many arguments for format
[-Werror=format-extra-args]
                     NULL);
                     ^

The documentation for `__attribute__((format(...)))` in GCC

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

States that the second index must be 0 for functions that are not
available to be checked, like for vprintf-style functions. In this case
it's also appropriate because of the trailing arguments.

The sd-journal API in systemd, upon which the structured logging API is
modelled, also uses 0 as the second argument for the format attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
2016-07-19 11:10:34 +01:00
Ting-Wei Lan
07932996fa gmessages: Add G_GNUC_PRINTF mark for g_log_structured
It is required to avoid non-literal format string warning when using clang.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
2016-07-19 01:55:06 +08:00
Daniel Mustieles
0346254502 Updated Spanish translation 2016-07-18 16:45:41 +02:00
Chun-wei Fan
97972471ca gio/glocalfile.c: Windows: Define ECANCELED if not already defined
Older Visual Studio may not have it defined, so define it like what is
defined for Visual Studio 2010 and later.
2016-07-18 14:41:17 +08:00
Chun-wei Fan
c08b1a6ae5 glib/gmessages.c: Use G_VA_COPY() instead of va_copy()
Some compilers may not support va_copy(), so use the G_VA_COPY macro so
that things can be supported properly on all supported compilers.
2016-07-18 14:25:52 +08:00
Chun-wei Fan
c6aee1bf15 Visual Studio builds: Build the gio tool
https://bugzilla.gnome.org/show_bug.cgi?id=768357
2016-07-18 10:39:20 +08:00
Matthias Clasen
8d68a27f70 Update 2016-07-17 13:17:55 -04:00
Philip Withnall
12acd90d8a gmessages: Document namespacing recommendation for structured log fields
We recommend that all custom log fields are namespaced to avoid
collisions.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
2016-07-17 17:10:41 +01:00