/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities the gir-to-d pakage


module glib.MessageLog;

private import glib.Str;
private import glib.c.functions;
public  import glib.c.types;


/** */
public struct MessageLog
{

	/**
	 * The default log handler set up by GLib; [func@GLib.log_set_default_handler]
	 * allows to install an alternate default log handler.
	 *
	 * This is used if no log handler has been set for the particular log
	 * domain and log level combination. It outputs the message to `stderr`
	 * or `stdout` and if the log level is fatal it calls [func@GLib.BREAKPOINT]. It automatically
	 * prints a new-line character after the message, so one does not need to be
	 * manually included in @message.
	 *
	 * The behavior of this log handler can be influenced by a number of
	 * environment variables:
	 *
	 * - `G_MESSAGES_PREFIXED`: A `:`-separated list of log levels for which
	 * messages should be prefixed by the program name and PID of the
	 * application.
	 * - `G_MESSAGES_DEBUG`: A space-separated list of log domains for
	 * which debug and informational messages are printed. By default
	 * these messages are not printed. If you need to set the allowed
	 * domains at runtime, use [func@GLib.log_writer_default_set_debug_domains].
	 * - `DEBUG_INVOCATION`: If set to `1`, this is equivalent to
	 * `G_MESSAGES_DEBUG=all`. `DEBUG_INVOCATION` is a standard environment
	 * variable set by systemd to prompt debug output. (Since: 2.84)
	 *
	 * `stderr` is used for levels [flags@GLib.LogLevelFlags.LEVEL_ERROR],
	 * [flags@GLib.LogLevelFlags.LEVEL_CRITICAL], [flags@GLib.LogLevelFlags.LEVEL_WARNING] and
	 * [flags@GLib.LogLevelFlags.LEVEL_MESSAGE]. `stdout` is used for
	 * the rest, unless `stderr` was requested by
	 * [func@GLib.log_writer_default_set_use_stderr].
	 *
	 * This has no effect if structured logging is enabled; see
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * Params:
	 *     logDomain = the log domain of the message, or `NULL` for the
	 *         default `""` application domain
	 *     logLevel = the level of the message
	 *     message = the message
	 *     unusedData = data passed from [func@GLib.log] which is unused
	 */
	public static void logDefaultHandler(string logDomain, GLogLevelFlags logLevel, string message, void* unusedData)
	{
		g_log_default_handler(Str.toStringz(logDomain), logLevel, Str.toStringz(message), unusedData);
	}

	/**
	 * Removes the log handler.
	 *
	 * This has no effect if structured logging is enabled; see
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * Params:
	 *     logDomain = the log domain
	 *     handlerId = the ID of the handler, which was returned
	 *         in [func@GLib.log_set_handler]
	 */
	public static void logRemoveHandler(string logDomain, uint handlerId)
	{
		g_log_remove_handler(Str.toStringz(logDomain), handlerId);
	}

	/**
	 * Sets the message levels which are always fatal, in any log domain.
	 *
	 * When a message with any of these levels is logged the program terminates.
	 * You can only set the levels defined by GLib to be fatal.
	 * [flags@GLib.LogLevelFlags.LEVEL_ERROR] is always fatal.
	 *
	 * You can also make some message levels fatal at runtime by setting
	 * the `G_DEBUG` environment variable (see
	 * [Running GLib Applications](glib-running.html)).
	 *
	 * Libraries should not call this function, as it affects all messages logged
	 * by a process, including those from other libraries.
	 *
	 * Structured log messages (using [func@GLib.log_structured] and
	 * [func@GLib.log_structured_array]) are fatal only if the default log writer is used;
	 * otherwise it is up to the writer function to determine which log messages
	 * are fatal. See [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * Params:
	 *     fatalMask = the mask containing bits set for each level of error which is
	 *         to be fatal
	 *
	 * Returns: the old fatal mask
	 */
	public static GLogLevelFlags logSetAlwaysFatal(GLogLevelFlags fatalMask)
	{
		return g_log_set_always_fatal(fatalMask);
	}

	/**
	 * Installs a default log handler which is used if no
	 * log handler has been set for the particular log domain
	 * and log level combination.
	 *
	 * By default, GLib uses [func@GLib.log_default_handler] as default log handler.
	 *
	 * This has no effect if structured logging is enabled; see
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * Params:
	 *     logFunc = the log handler function
	 *     userData = data passed to the log handler
	 *
	 * Returns: the previous default log handler
	 *
	 * Since: 2.6
	 */
	public static GLogFunc logSetDefaultHandler(GLogFunc logFunc, void* userData)
	{
		return g_log_set_default_handler(logFunc, userData);
	}

	/**
	 * Sets the log levels which are fatal in the given domain.
	 *
	 * [flags@GLib.LogLevelFlags.LEVEL_ERROR] is always fatal.
	 *
	 * This has no effect on structured log messages (using [func@GLib.log_structured] or
	 * [func@GLib.log_structured_array]). To change the fatal behaviour for specific log
	 * messages, programs must install a custom log writer function using
	 * [func@GLib.log_set_writer_func]. See
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * This function is mostly intended to be used with
	 * [flags@GLib.LogLevelFlags.LEVEL_CRITICAL].  You should typically not set
	 * [flags@GLib.LogLevelFlags.LEVEL_WARNING], [flags@GLib.LogLevelFlags.LEVEL_MESSAGE], [flags@GLib.LogLevelFlags.LEVEL_INFO] or
	 * [flags@GLib.LogLevelFlags.LEVEL_DEBUG] as fatal except inside of test programs.
	 *
	 * Params:
	 *     logDomain = the log domain
	 *     fatalMask = the new fatal mask
	 *
	 * Returns: the old fatal mask for the log domain
	 */
	public static GLogLevelFlags logSetFatalMask(string logDomain, GLogLevelFlags fatalMask)
	{
		return g_log_set_fatal_mask(Str.toStringz(logDomain), fatalMask);
	}

	/**
	 * Sets the log handler for a domain and a set of log levels.
	 *
	 * To handle fatal and recursive messages the @log_levels parameter
	 * must be combined with the [flags@GLib.LogLevelFlags.FLAG_FATAL] and [flags@GLib.LogLevelFlags.FLAG_RECURSION]
	 * bit flags.
	 *
	 * Note that since the [flags@GLib.LogLevelFlags.LEVEL_ERROR] log level is always fatal, if
	 * you want to set a handler for this log level you must combine it with
	 * [flags@GLib.LogLevelFlags.FLAG_FATAL].
	 *
	 * This has no effect if structured logging is enabled; see
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * The `log_domain` parameter can be set to `NULL` or an empty string to use the default
	 * application domain.
	 *
	 * Here is an example for adding a log handler for all warning messages
	 * in the default domain:
	 *
	 * ```c
	 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
	 * ```
	 *
	 * This example adds a log handler for all critical messages from GTK:
	 *
	 * ```c
	 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
	 * ```
	 *
	 * This example adds a log handler for all messages from GLib:
	 *
	 * ```c
	 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
	 * ```
	 *
	 * Params:
	 *     logDomain = the log domain
	 *         application domain
	 *     logLevels = the log levels to apply the log handler for.
	 *         To handle fatal and recursive messages as well, combine
	 *         the log levels with the [flags@GLib.LogLevelFlags.FLAG_FATAL] and
	 *         [flags@GLib.LogLevelFlags.FLAG_RECURSION] bit flags.
	 *     logFunc = the log handler function
	 *     userData = data passed to the log handler
	 *
	 * Returns: the id of the new handler
	 */
	public static uint logSetHandler(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData)
	{
		return g_log_set_handler(Str.toStringz(logDomain), logLevels, logFunc, userData);
	}

	/**
	 * Like [func@GLib.log_set_handler], but takes a destroy notify for the @user_data.
	 *
	 * This has no effect if structured logging is enabled; see
	 * [Using Structured Logging](logging.html#using-structured-logging).
	 *
	 * The `log_domain` parameter can be set to `NULL` or an empty string to use the default
	 * application domain.
	 *
	 * Params:
	 *     logDomain = the log domain
	 *         application domain
	 *     logLevels = the log levels to apply the log handler for.
	 *         To handle fatal and recursive messages as well, combine
	 *         the log levels with the [flags@GLib.LogLevelFlags.FLAG_FATAL] and
	 *         [flags@GLib.LogLevelFlags.FLAG_RECURSION] bit flags.
	 *     logFunc = the log handler function
	 *     userData = data passed to the log handler
	 *     destroy = destroy notify for @user_data, or `NULL`
	 *
	 * Returns: the ID of the new handler
	 *
	 * Since: 2.46
	 */
	public static uint logSetHandlerFull(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData, GDestroyNotify destroy)
	{
		return g_log_set_handler_full(Str.toStringz(logDomain), logLevels, logFunc, userData, destroy);
	}

	/**
	 * Logs an error or debugging message.
	 *
	 * If the log level has been set as fatal, [func@GLib.BREAKPOINT] is called
	 * to terminate the program. See the documentation for [func@GLib.BREAKPOINT] for
	 * details of the debugging options this provides.
	 *
	 * If [func@GLib.log_default_handler] is used as the log handler function, a new-line
	 * character will automatically be appended to @..., and need not be entered
	 * manually.
	 *
	 * If [structured logging is enabled](logging.html#using-structured-logging) this will
	 * output via the structured log writer function (see [func@GLib.log_set_writer_func]).
	 *
	 * The `log_domain` parameter can be set to `NULL` or an empty string to use the default
	 * application domain.
	 *
	 * Params:
	 *     logDomain = the log domain
	 *         application domain
	 *     logLevel = the log level
	 *     format = the message format. See the `printf()` documentation
	 *     args = the parameters to insert into the format string
	 */
	public static void logv(string logDomain, GLogLevelFlags logLevel, string format, void* args)
	{
		g_logv(Str.toStringz(logDomain), logLevel, Str.toStringz(format), args);
	}
}
