GLib.log_writer_default
Description: Reference for GLib.log_writer_default

### Function

# GLiblog_writer_default

since: 2.50

#### Declaration [src]

    GLogWriterOutput
    g_log_writer_default (
      GLogLevelFlags log_level,
      const GLogField* fields,
      gsize n_fields,
      gpointer user_data
    )

#### Description [src]

Format a structured log message and output it to the default log destination for the platform.

On Linux, this is typically the systemd journal, falling back to `stdout` or `stderr` if running from the terminal or if output is being redirected to a file.

Support for other platform-specific logging mechanisms may be added in future. Distributors of GLib may modify this function to impose their own (documented) platform-specific log writing policies.

This is suitable for use as a `GLogWriterFunc`, and is the default writer used if no other is set using `g_log_set_writer_func()`.

As with `g_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 `DEBUG_INVOCATION=1` is set in the environment, or set at runtime by `g_log_writer_default_set_debug_domains()`.

`g_log_writer_default()` uses the mask set by `g_log_set_always_fatal()` to determine which messages are fatal. When using a custom writer function instead it is up to the writer function to determine which log messages are fatal.

Available since: 2.50

#### Parameters

`log_level`

  Type: `GLogLevelFlags`

  Log level, either from `GLogLevelFlags`, or a user-defined level.

`fields`

  Type: An array of `GLogField`

  Key–value pairs of structured data forming the log message.

  The length of the array is specified in the `n_fields` argument.
  The data is owned by the caller of the function.

`n_fields`

  Type: `gsize`

  Number of elements in the `fields` array.

`user_data`

  Type: `gpointer`

  User data passed to `g_log_set_writer_func()`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

#### Return value

Type: `GLogWriterOutput`

`G_LOG_WRITER_HANDLED` on success, `G_LOG_WRITER_UNHANDLED` otherwise.