1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.MessageLog;
26 
27 private import glib.Str;
28 private import gtkc.glib;
29 public  import gtkc.glibtypes;
30 
31 
32 public struct MessageLog
33 {
34 	/**
35 	 */
36 
37 	/**
38 	 * The default log handler set up by GLib; g_log_set_default_handler()
39 	 * allows to install an alternate default log handler.
40 	 * This is used if no log handler has been set for the particular log
41 	 * domain and log level combination. It outputs the message to stderr
42 	 * or stdout and if the log level is fatal it calls abort(). It automatically
43 	 * prints a new-line character after the message, so one does not need to be
44 	 * manually included in @message.
45 	 *
46 	 * The behavior of this log handler can be influenced by a number of
47 	 * environment variables:
48 	 *
49 	 * - `G_MESSAGES_PREFIXED`: A :-separated list of log levels for which
50 	 * messages should be prefixed by the program name and PID of the
51 	 * aplication.
52 	 *
53 	 * - `G_MESSAGES_DEBUG`: A space-separated list of log domains for
54 	 * which debug and informational messages are printed. By default
55 	 * these messages are not printed.
56 	 *
57 	 * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
58 	 * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
59 	 * the rest.
60 	 *
61 	 * Params:
62 	 *     logDomain = the log domain of the message
63 	 *     logLevel = the level of the message
64 	 *     message = the message
65 	 *     unusedData = data passed from g_log() which is unused
66 	 */
67 	public static void logDefaultHandler(string logDomain, GLogLevelFlags logLevel, string message, void* unusedData)
68 	{
69 		g_log_default_handler(Str.toStringz(logDomain), logLevel, Str.toStringz(message), unusedData);
70 	}
71 
72 	/**
73 	 * Removes the log handler.
74 	 *
75 	 * Params:
76 	 *     logDomain = the log domain
77 	 *     handlerId = the id of the handler, which was returned
78 	 *         in g_log_set_handler()
79 	 */
80 	public static void logRemoveHandler(string logDomain, uint handlerId)
81 	{
82 		g_log_remove_handler(Str.toStringz(logDomain), handlerId);
83 	}
84 
85 	/**
86 	 * Sets the message levels which are always fatal, in any log domain.
87 	 * When a message with any of these levels is logged the program terminates.
88 	 * You can only set the levels defined by GLib to be fatal.
89 	 * %G_LOG_LEVEL_ERROR is always fatal.
90 	 *
91 	 * You can also make some message levels fatal at runtime by setting
92 	 * the `G_DEBUG` environment variable (see
93 	 * [Running GLib Applications](glib-running.html)).
94 	 *
95 	 * Params:
96 	 *     fatalMask = the mask containing bits set for each level
97 	 *         of error which is to be fatal
98 	 *
99 	 * Return: the old fatal mask
100 	 */
101 	public static GLogLevelFlags logSetAlwaysFatal(GLogLevelFlags fatalMask)
102 	{
103 		return g_log_set_always_fatal(fatalMask);
104 	}
105 
106 	/**
107 	 * Installs a default log handler which is used if no
108 	 * log handler has been set for the particular log domain
109 	 * and log level combination. By default, GLib uses
110 	 * g_log_default_handler() as default log handler.
111 	 *
112 	 * Params:
113 	 *     logFunc = the log handler function
114 	 *     userData = data passed to the log handler
115 	 *
116 	 * Return: the previous default log handler
117 	 *
118 	 * Since: 2.6
119 	 */
120 	public static GLogFunc logSetDefaultHandler(GLogFunc logFunc, void* userData)
121 	{
122 		return g_log_set_default_handler(logFunc, userData);
123 	}
124 
125 	/**
126 	 * Sets the log levels which are fatal in the given domain.
127 	 * %G_LOG_LEVEL_ERROR is always fatal.
128 	 *
129 	 * Params:
130 	 *     logDomain = the log domain
131 	 *     fatalMask = the new fatal mask
132 	 *
133 	 * Return: the old fatal mask for the log domain
134 	 */
135 	public static GLogLevelFlags logSetFatalMask(string logDomain, GLogLevelFlags fatalMask)
136 	{
137 		return g_log_set_fatal_mask(Str.toStringz(logDomain), fatalMask);
138 	}
139 
140 	/**
141 	 * Sets the log handler for a domain and a set of log levels.
142 	 * To handle fatal and recursive messages the @log_levels parameter
143 	 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
144 	 * bit flags.
145 	 *
146 	 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
147 	 * you want to set a handler for this log level you must combine it with
148 	 * #G_LOG_FLAG_FATAL.
149 	 *
150 	 * Here is an example for adding a log handler for all warning messages
151 	 * in the default domain:
152 	 * |[<!-- language="C" -->
153 	 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
154 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
155 	 * ]|
156 	 *
157 	 * This example adds a log handler for all critical messages from GTK+:
158 	 * |[<!-- language="C" -->
159 	 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
160 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
161 	 * ]|
162 	 *
163 	 * This example adds a log handler for all messages from GLib:
164 	 * |[<!-- language="C" -->
165 	 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
166 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
167 	 * ]|
168 	 *
169 	 * Params:
170 	 *     logDomain = the log domain, or %NULL for the default ""
171 	 *         application domain
172 	 *     logLevels = the log levels to apply the log handler for.
173 	 *         To handle fatal and recursive messages as well, combine
174 	 *         the log levels with the #G_LOG_FLAG_FATAL and
175 	 *         #G_LOG_FLAG_RECURSION bit flags.
176 	 *     logFunc = the log handler function
177 	 *     userData = data passed to the log handler
178 	 *
179 	 * Return: the id of the new handler
180 	 */
181 	public static uint logSetHandler(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData)
182 	{
183 		return g_log_set_handler(Str.toStringz(logDomain), logLevels, logFunc, userData);
184 	}
185 
186 	/**
187 	 * Like g_log_sets_handler(), but takes a destroy notify for the @user_data.
188 	 *
189 	 * Params:
190 	 *     logDomain = the log domain, or %NULL for the default ""
191 	 *         application domain
192 	 *     logLevels = the log levels to apply the log handler for.
193 	 *         To handle fatal and recursive messages as well, combine
194 	 *         the log levels with the #G_LOG_FLAG_FATAL and
195 	 *         #G_LOG_FLAG_RECURSION bit flags.
196 	 *     logFunc = the log handler function
197 	 *     userData = data passed to the log handler
198 	 *     destroy = destroy notify for @user_data, or %NULL
199 	 *
200 	 * Return: the id of the new handler
201 	 *
202 	 * Since: 2.46
203 	 */
204 	public static uint logSetHandlerFull(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData, GDestroyNotify destroy)
205 	{
206 		return g_log_set_handler_full(Str.toStringz(logDomain), logLevels, logFunc, userData, destroy);
207 	}
208 
209 	/**
210 	 * Logs an error or debugging message.
211 	 *
212 	 * If the log level has been set as fatal, the abort()
213 	 * function is called to terminate the program.
214 	 *
215 	 * If g_log_default_handler() is used as the log handler function, a new-line
216 	 * character will automatically be appended to @..., and need not be entered
217 	 * manually.
218 	 *
219 	 * Params:
220 	 *     logDomain = the log domain
221 	 *     logLevel = the log level
222 	 *     format = the message format. See the printf() documentation
223 	 *     args = the parameters to insert into the format string
224 	 */
225 	public static void logv(string logDomain, GLogLevelFlags logLevel, string format, void* args)
226 	{
227 		g_logv(Str.toStringz(logDomain), logLevel, Str.toStringz(format), args);
228 	}
229 }