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