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 * Params: 61 * logDomain = the log domain of the message 62 * logLevel = the level of the message 63 * message = the message 64 * unusedData = data passed from g_log() which is unused 65 */ 66 public static void logDefaultHandler(string logDomain, GLogLevelFlags logLevel, string message, void* unusedData) 67 { 68 g_log_default_handler(Str.toStringz(logDomain), logLevel, Str.toStringz(message), unusedData); 69 } 70 71 /** 72 * Removes the log handler. 73 * 74 * Params: 75 * logDomain = the log domain 76 * handlerId = the id of the handler, which was returned 77 * in g_log_set_handler() 78 */ 79 public static void logRemoveHandler(string logDomain, uint handlerId) 80 { 81 g_log_remove_handler(Str.toStringz(logDomain), handlerId); 82 } 83 84 /** 85 * Sets the message levels which are always fatal, in any log domain. 86 * When a message with any of these levels is logged the program terminates. 87 * You can only set the levels defined by GLib to be fatal. 88 * %G_LOG_LEVEL_ERROR is always fatal. 89 * 90 * You can also make some message levels fatal at runtime by setting 91 * the `G_DEBUG` environment variable (see 92 * [Running GLib Applications](glib-running.html)). 93 * 94 * Params: 95 * fatalMask = the mask containing bits set for each level 96 * of error which is to be fatal 97 * 98 * Return: the old fatal mask 99 */ 100 public static GLogLevelFlags logSetAlwaysFatal(GLogLevelFlags fatalMask) 101 { 102 return g_log_set_always_fatal(fatalMask); 103 } 104 105 /** 106 * Installs a default log handler which is used if no 107 * log handler has been set for the particular log domain 108 * and log level combination. By default, GLib uses 109 * g_log_default_handler() as default log handler. 110 * 111 * Params: 112 * logFunc = the log handler function 113 * userData = data passed to the log handler 114 * 115 * Return: the previous default log handler 116 * 117 * Since: 2.6 118 */ 119 public static GLogFunc logSetDefaultHandler(GLogFunc logFunc, void* userData) 120 { 121 return g_log_set_default_handler(logFunc, userData); 122 } 123 124 /** 125 * Sets the log levels which are fatal in the given domain. 126 * %G_LOG_LEVEL_ERROR is always fatal. 127 * 128 * Params: 129 * logDomain = the log domain 130 * fatalMask = the new fatal mask 131 * 132 * Return: the old fatal mask for the log domain 133 */ 134 public static GLogLevelFlags logSetFatalMask(string logDomain, GLogLevelFlags fatalMask) 135 { 136 return g_log_set_fatal_mask(Str.toStringz(logDomain), fatalMask); 137 } 138 139 /** 140 * Sets the log handler for a domain and a set of log levels. 141 * To handle fatal and recursive messages the @log_levels parameter 142 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION 143 * bit flags. 144 * 145 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if 146 * you want to set a handler for this log level you must combine it with 147 * #G_LOG_FLAG_FATAL. 148 * 149 * Here is an example for adding a log handler for all warning messages 150 * in the default domain: 151 * |[<!-- language="C" --> 152 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL 153 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 154 * ]| 155 * 156 * This example adds a log handler for all critical messages from GTK+: 157 * |[<!-- language="C" --> 158 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL 159 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 160 * ]| 161 * 162 * This example adds a log handler for all messages from GLib: 163 * |[<!-- language="C" --> 164 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL 165 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 166 * ]| 167 * 168 * Params: 169 * logDomain = the log domain, or %NULL for the default "" 170 * application domain 171 * logLevels = the log levels to apply the log handler for. 172 * To handle fatal and recursive messages as well, combine 173 * the log levels with the #G_LOG_FLAG_FATAL and 174 * #G_LOG_FLAG_RECURSION bit flags. 175 * logFunc = the log handler function 176 * userData = data passed to the log handler 177 * 178 * Return: the id of the new handler 179 */ 180 public static uint logSetHandler(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData) 181 { 182 return g_log_set_handler(Str.toStringz(logDomain), logLevels, logFunc, userData); 183 } 184 185 /** 186 * Like g_log_sets_handler(), but takes a destroy notify for the @user_data. 187 * 188 * Params: 189 * logDomain = the log domain, or %NULL for the default "" 190 * application domain 191 * logLevels = the log levels to apply the log handler for. 192 * To handle fatal and recursive messages as well, combine 193 * the log levels with the #G_LOG_FLAG_FATAL and 194 * #G_LOG_FLAG_RECURSION bit flags. 195 * logFunc = the log handler function 196 * userData = data passed to the log handler 197 * destroy = destroy notify for @user_data, or %NULL 198 * 199 * Return: the id of the new handler 200 * 201 * Since: 2.46 202 */ 203 public static uint logSetHandlerFull(string logDomain, GLogLevelFlags logLevels, GLogFunc logFunc, void* userData, GDestroyNotify destroy) 204 { 205 return g_log_set_handler_full(Str.toStringz(logDomain), logLevels, logFunc, userData, destroy); 206 } 207 208 /** 209 * Logs an error or debugging message. 210 * 211 * If the log level has been set as fatal, the abort() 212 * function is called to terminate the program. 213 * 214 * If g_log_default_handler() is used as the log handler function, a new-line 215 * character will automatically be appended to @..., and need not be entered 216 * manually. 217 * 218 * Params: 219 * logDomain = the log domain 220 * logLevel = the log level 221 * format = the message format. See the printf() documentation 222 * args = the parameters to insert into the format string 223 */ 224 public static void logv(string logDomain, GLogLevelFlags logLevel, string format, void* args) 225 { 226 g_logv(Str.toStringz(logDomain), logLevel, Str.toStringz(format), args); 227 } 228 }