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 glib.c.functions;
29 public  import glib.c.types;
30 public  import gtkc.glibtypes;
31 
32 
33 /** */
34 public struct MessageLog
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 G_BREAKPOINT(). 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 	 * This has no effect if structured logging is enabled; see
62 	 * [Using Structured Logging][using-structured-logging].
63 	 *
64 	 * Params:
65 	 *     logDomain = the log domain of the message, or %NULL for the
66 	 *         default "" application domain
67 	 *     logLevel = the level of the message
68 	 *     message = the message
69 	 *     unusedData = data passed from g_log() which is unused
70 	 */
71 	public static void logDefaultHandler(string logDomain, GLogLevelFlags logLevel, string message, void* unusedData)
72 	{
73 		g_log_default_handler(Str.toStringz(logDomain), logLevel, Str.toStringz(message), unusedData);
74 	}
75 
76 	/**
77 	 * Removes the log handler.
78 	 *
79 	 * This has no effect if structured logging is enabled; see
80 	 * [Using Structured Logging][using-structured-logging].
81 	 *
82 	 * Params:
83 	 *     logDomain = the log domain
84 	 *     handlerId = the id of the handler, which was returned
85 	 *         in g_log_set_handler()
86 	 */
87 	public static void logRemoveHandler(string logDomain, uint handlerId)
88 	{
89 		g_log_remove_handler(Str.toStringz(logDomain), handlerId);
90 	}
91 
92 	/**
93 	 * Sets the message levels which are always fatal, in any log domain.
94 	 * When a message with any of these levels is logged the program terminates.
95 	 * You can only set the levels defined by GLib to be fatal.
96 	 * %G_LOG_LEVEL_ERROR is always fatal.
97 	 *
98 	 * You can also make some message levels fatal at runtime by setting
99 	 * the `G_DEBUG` environment variable (see
100 	 * [Running GLib Applications](glib-running.html)).
101 	 *
102 	 * Libraries should not call this function, as it affects all messages logged
103 	 * by a process, including those from other libraries.
104 	 *
105 	 * Structured log messages (using g_log_structured() and
106 	 * g_log_structured_array()) are fatal only if the default log writer is used;
107 	 * otherwise it is up to the writer function to determine which log messages
108 	 * are fatal. See [Using Structured Logging][using-structured-logging].
109 	 *
110 	 * Params:
111 	 *     fatalMask = the mask containing bits set for each level
112 	 *         of error which is to be fatal
113 	 *
114 	 * Returns: the old fatal mask
115 	 */
116 	public static GLogLevelFlags logSetAlwaysFatal(GLogLevelFlags fatalMask)
117 	{
118 		return g_log_set_always_fatal(fatalMask);
119 	}
120 
121 	/**
122 	 * Installs a default log handler which is used if no
123 	 * log handler has been set for the particular log domain
124 	 * and log level combination. By default, GLib uses
125 	 * g_log_default_handler() as default log handler.
126 	 *
127 	 * This has no effect if structured logging is enabled; see
128 	 * [Using Structured Logging][using-structured-logging].
129 	 *
130 	 * Params:
131 	 *     logFunc = the log handler function
132 	 *     userData = data passed to the log handler
133 	 *
134 	 * Returns: the previous default log handler
135 	 *
136 	 * Since: 2.6
137 	 */
138 	public static GLogFunc logSetDefaultHandler(GLogFunc logFunc, void* userData)
139 	{
140 		return g_log_set_default_handler(logFunc, userData);
141 	}
142 
143 	/**
144 	 * Sets the log levels which are fatal in the given domain.
145 	 * %G_LOG_LEVEL_ERROR is always fatal.
146 	 *
147 	 * This has no effect on structured log messages (using g_log_structured() or
148 	 * g_log_structured_array()). To change the fatal behaviour for specific log
149 	 * messages, programs must install a custom log writer function using
150 	 * g_log_set_writer_func(). See
151 	 * [Using Structured Logging][using-structured-logging].
152 	 *
153 	 * This function is mostly intended to be used with
154 	 * %G_LOG_LEVEL_CRITICAL.  You should typically not set
155 	 * %G_LOG_LEVEL_WARNING, %G_LOG_LEVEL_MESSAGE, %G_LOG_LEVEL_INFO or
156 	 * %G_LOG_LEVEL_DEBUG as fatal except inside of test programs.
157 	 *
158 	 * Params:
159 	 *     logDomain = the log domain
160 	 *     fatalMask = the new fatal mask
161 	 *
162 	 * Returns: the old fatal mask for the log domain
163 	 */
164 	public static GLogLevelFlags logSetFatalMask(string logDomain, GLogLevelFlags fatalMask)
165 	{
166 		return g_log_set_fatal_mask(Str.toStringz(logDomain), fatalMask);
167 	}
168 
169 	/**
170 	 * Sets the log handler for a domain and a set of log levels.
171 	 * To handle fatal and recursive messages the @log_levels parameter
172 	 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
173 	 * bit flags.
174 	 *
175 	 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
176 	 * you want to set a handler for this log level you must combine it with
177 	 * #G_LOG_FLAG_FATAL.
178 	 *
179 	 * This has no effect if structured logging is enabled; see
180 	 * [Using Structured Logging][using-structured-logging].
181 	 *
182 	 * Here is an example for adding a log handler for all warning messages
183 	 * in the default domain:
184 	 * |[<!-- language="C" -->
185 	 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
186 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
187 	 * ]|
188 	 *
189 	 * This example adds a log handler for all critical messages from GTK+:
190 	 * |[<!-- language="C" -->
191 	 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
192 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
193 	 * ]|
194 	 *
195 	 * This example adds a log handler for all messages from GLib:
196 	 * |[<!-- language="C" -->
197 	 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
198 	 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
199 	 * ]|
200 	 *
201 	 * Params:
202 	 *     logDomain = the log domain, or %NULL for the default ""
203 	 *         application domain
204 	 *     logLevels = the log levels to apply the log handler for.
205 	 *         To handle fatal and recursive messages as well, combine
206 	 *         the log levels with the #G_LOG_FLAG_FATAL and
207 	 *         #G_LOG_FLAG_RECURSION bit flags.
208 	 *     logFunc = the log handler function
209 	 *     userData = data passed to the log handler
210 	 *
211 	 * Returns: the id of the new handler
212 	 */
213 	public static uint logSetHandler(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData)
214 	{
215 		return g_log_set_handler(Str.toStringz(logDomain), logLevels, logFunc, userData);
216 	}
217 
218 	/**
219 	 * Like g_log_set_handler(), but takes a destroy notify for the @user_data.
220 	 *
221 	 * This has no effect if structured logging is enabled; see
222 	 * [Using Structured Logging][using-structured-logging].
223 	 *
224 	 * Params:
225 	 *     logDomain = the log domain, or %NULL for the default ""
226 	 *         application domain
227 	 *     logLevels = the log levels to apply the log handler for.
228 	 *         To handle fatal and recursive messages as well, combine
229 	 *         the log levels with the #G_LOG_FLAG_FATAL and
230 	 *         #G_LOG_FLAG_RECURSION bit flags.
231 	 *     logFunc = the log handler function
232 	 *     userData = data passed to the log handler
233 	 *     destroy = destroy notify for @user_data, or %NULL
234 	 *
235 	 * Returns: the id of the new handler
236 	 *
237 	 * Since: 2.46
238 	 */
239 	public static uint logSetHandlerFull(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData, GDestroyNotify destroy)
240 	{
241 		return g_log_set_handler_full(Str.toStringz(logDomain), logLevels, logFunc, userData, destroy);
242 	}
243 
244 	/**
245 	 * Logs an error or debugging message.
246 	 *
247 	 * If the log level has been set as fatal, G_BREAKPOINT() is called
248 	 * to terminate the program. See the documentation for G_BREAKPOINT() for
249 	 * details of the debugging options this provides.
250 	 *
251 	 * If g_log_default_handler() is used as the log handler function, a new-line
252 	 * character will automatically be appended to @..., and need not be entered
253 	 * manually.
254 	 *
255 	 * If [structured logging is enabled][using-structured-logging] this will
256 	 * output via the structured log writer function (see g_log_set_writer_func()).
257 	 *
258 	 * Params:
259 	 *     logDomain = the log domain, or %NULL for the default ""
260 	 *         application domain
261 	 *     logLevel = the log level
262 	 *     format = the message format. See the printf() documentation
263 	 *     args = the parameters to insert into the format string
264 	 */
265 	public static void logv(string logDomain, GLogLevelFlags logLevel, string format, void* args)
266 	{
267 		g_logv(Str.toStringz(logDomain), logLevel, Str.toStringz(format), args);
268 	}
269 }