writer_default_would_drop


Description:

[ Version ( since = "2.68" ) ]
public bool writer_default_would_drop (LogLevelFlags log_level, string log_domain)

Check whether [func@GLib.

log_writer_default] and [func@GLib.log_default_handler] would ignore a message with the given domain and level.

As with [func@GLib.log_default_handler], this function drops debug and informational messages unless their log domain (or `all`) is listed in the space-separated `G_MESSAGES_DEBUG` environment variable, or by [func@GLib.log_writer_default_set_debug_domains].

This can be used when implementing log writers with the same filtering behaviour as the default, but a different destination or output format:

```c if (g_log_writer_default_would_drop (log_level, log_domain)) return G_LOG_WRITER_HANDLED; ]|

or to skip an expensive computation if it is only needed for a debugging message, and `G_MESSAGES_DEBUG` is not set:

```c if (!g_log_writer_default_would_drop (G_LOG_LEVEL_DEBUG, G_LOG_DOMAIN)) { g_autofree gchar *result = expensive_computation (my_object);

g_debug ("my_object result: s", result); } ```

Parameters:

log_level

log level, either from [type@GLib.LogLevelFlags], or a user-defined level

log_domain

log domain

Returns:

`TRUE` if the log message would be dropped by GLib’s default log handlers


Namespace: GLib.Log
Package: glib-2.0