Function

GLibLogWriterFunc

since: 2.50

Declaration

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

Description [src]

Writer function for log entries. A log entry is a collection of one or more GLogFields, using the standard field names from journal specification. See g_log_structured() for more information.

Writer functions must ignore fields which they do not recognise, unless they can write arbitrary binary output, as field values may be arbitrary binary.

log_level is guaranteed to be included in fields as the PRIORITY field, but is provided separately for convenience of deciding whether or where to output the log entry.

Writer functions should return G_LOG_WRITER_HANDLED if they handled the log message successfully or if they deliberately ignored it. If there was an error handling the message (for example, if the writer function is meant to send messages to a remote logging server and there is a network error), it should return G_LOG_WRITER_UNHANDLED. This allows writer functions to be chained and fall back to simpler handlers in case of failure.

Available since: 2.50

Parameters

log_level

Type: GLogLevelFlags

Log level of the message.

fields

Type: An array of GLogField

Fields forming the 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 fields.

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 if the log entry was handled successfully; G_LOG_WRITER_UNHANDLED otherwise.