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 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 * 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 * Params: 154 * logDomain = the log domain 155 * fatalMask = the new fatal mask 156 * 157 * Returns: the old fatal mask for the log domain 158 */ 159 public static GLogLevelFlags logSetFatalMask(string logDomain, GLogLevelFlags fatalMask) 160 { 161 return g_log_set_fatal_mask(Str.toStringz(logDomain), fatalMask); 162 } 163 164 /** 165 * Sets the log handler for a domain and a set of log levels. 166 * To handle fatal and recursive messages the @log_levels parameter 167 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION 168 * bit flags. 169 * 170 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if 171 * you want to set a handler for this log level you must combine it with 172 * #G_LOG_FLAG_FATAL. 173 * 174 * This has no effect if structured logging is enabled; see 175 * [Using Structured Logging][using-structured-logging]. 176 * 177 * Here is an example for adding a log handler for all warning messages 178 * in the default domain: 179 * |[<!-- language="C" --> 180 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL 181 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 182 * ]| 183 * 184 * This example adds a log handler for all critical messages from GTK+: 185 * |[<!-- language="C" --> 186 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL 187 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 188 * ]| 189 * 190 * This example adds a log handler for all messages from GLib: 191 * |[<!-- language="C" --> 192 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL 193 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 194 * ]| 195 * 196 * Params: 197 * logDomain = the log domain, or %NULL for the default "" 198 * application domain 199 * logLevels = the log levels to apply the log handler for. 200 * To handle fatal and recursive messages as well, combine 201 * the log levels with the #G_LOG_FLAG_FATAL and 202 * #G_LOG_FLAG_RECURSION bit flags. 203 * logFunc = the log handler function 204 * userData = data passed to the log handler 205 * 206 * Returns: the id of the new handler 207 */ 208 public static uint logSetHandler(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData) 209 { 210 return g_log_set_handler(Str.toStringz(logDomain), logLevels, logFunc, userData); 211 } 212 213 /** 214 * Like g_log_sets_handler(), but takes a destroy notify for the @user_data. 215 * 216 * This has no effect if structured logging is enabled; see 217 * [Using Structured Logging][using-structured-logging]. 218 * 219 * Params: 220 * logDomain = the log domain, or %NULL for the default "" 221 * application domain 222 * logLevels = the log levels to apply the log handler for. 223 * To handle fatal and recursive messages as well, combine 224 * the log levels with the #G_LOG_FLAG_FATAL and 225 * #G_LOG_FLAG_RECURSION bit flags. 226 * logFunc = the log handler function 227 * userData = data passed to the log handler 228 * destroy = destroy notify for @user_data, or %NULL 229 * 230 * Returns: the id of the new handler 231 * 232 * Since: 2.46 233 */ 234 public static uint logSetHandlerFull(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData, GDestroyNotify destroy) 235 { 236 return g_log_set_handler_full(Str.toStringz(logDomain), logLevels, logFunc, userData, destroy); 237 } 238 239 /** 240 * Logs an error or debugging message. 241 * 242 * If the log level has been set as fatal, the abort() 243 * function is called to terminate the program. 244 * 245 * If g_log_default_handler() is used as the log handler function, a new-line 246 * character will automatically be appended to @..., and need not be entered 247 * manually. 248 * 249 * If [structured logging is enabled][using-structured-logging] this will 250 * output via the structured log writer function (see g_log_set_writer_func()). 251 * 252 * Params: 253 * logDomain = the log domain, or %NULL for the default "" 254 * application domain 255 * logLevel = the log level 256 * format = the message format. See the printf() documentation 257 * args = the parameters to insert into the format string 258 */ 259 public static void logv(string logDomain, GLogLevelFlags logLevel, string format, void* args) 260 { 261 g_logv(Str.toStringz(logDomain), logLevel, Str.toStringz(format), args); 262 } 263 }