Add an example for g_on_error_query() usage. (#148716, Christian Persch)
authorMatthias Clasen <mclasen@redhat.com>
Mon, 23 Aug 2004 17:56:35 +0000 (17:56 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 23 Aug 2004 17:56:35 +0000 (17:56 +0000)
2004-08-23  Matthias Clasen  <mclasen@redhat.com>

* glib/tmpl/warnings.sgml: Add an example for
g_on_error_query() usage.  (#148716, Christian Persch)

docs/reference/ChangeLog
docs/reference/glib/tmpl/warnings.sgml

index bcd21e1..bda2bc9 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-23  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/tmpl/warnings.sgml: Add an example for
+       g_on_error_query() usage.  (#148716, Christian Persch)
+
 2004-08-12  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/tmpl/threads.sgml: Document the necessity to call
index 0ae921e..2bc9717 100644 (file)
@@ -151,9 +151,34 @@ The macro can be turned off in final releases of code by defining
 <!-- ##### FUNCTION g_on_error_query ##### -->
 <para>
 Prompts the user with <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
-This function is intended to be used for debugging use only.
-FIXME: How do you set it up?
-</para>
+This function is intended to be used for debugging use only. The following
+example shows how it can be used together with the g_log() functions.
+</para>
+<informalexample><programlisting>
+&num;include &lt;glib.h&gt;
+
+static void 
+log_handler (const gchar   *log_domain,
+            GLogLevelFlags log_level,
+            const gchar   *message,
+            gpointer       user_data)
+{
+  g_log_default_handler (log_domain, log_level, message, user_data);
+
+  g_on_error_query (MY_PROGRAM_NAME);
+}
+
+int main (int argc, char *argv[])
+{
+  g_log_set_handler (MY_LOG_DOMAIN,
+                    G_LOG_LEVEL_WARNING | 
+                     G_LOG_LEVEL_ERROR | 
+                     G_LOG_LEVEL_CRITICAL,
+                    log_handler,
+                    NULL);
+
+ /* ... */  
+</programlisting></informalexample>
 <para>
 If [E]xit is selected, the application terminates with a call to
 <function>_exit(0)</function>.