From 66a18b3f64900433734521a1ff42fb1d6974683f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 23 Aug 2004 17:56:35 +0000 Subject: [PATCH] Add an example for g_on_error_query() usage. (#148716, Christian Persch) 2004-08-23 Matthias Clasen * glib/tmpl/warnings.sgml: Add an example for g_on_error_query() usage. (#148716, Christian Persch) --- docs/reference/ChangeLog | 5 +++++ docs/reference/glib/tmpl/warnings.sgml | 31 ++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index bcd21e1..bda2bc9 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2004-08-23 Matthias Clasen + + * glib/tmpl/warnings.sgml: Add an example for + g_on_error_query() usage. (#148716, Christian Persch) + 2004-08-12 Matthias Clasen * glib/tmpl/threads.sgml: Document the necessity to call diff --git a/docs/reference/glib/tmpl/warnings.sgml b/docs/reference/glib/tmpl/warnings.sgml index 0ae921e..2bc9717 100644 --- a/docs/reference/glib/tmpl/warnings.sgml +++ b/docs/reference/glib/tmpl/warnings.sgml @@ -151,9 +151,34 @@ The macro can be turned off in final releases of code by defining Prompts the user with [E]xit, [H]alt, show [S]tack trace or [P]roceed. -This function is intended to be used for debugging use only. -FIXME: How do you set it up? - +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. + + +#include <glib.h> + +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); + + /* ... */ + If [E]xit is selected, the application terminates with a call to _exit(0). -- 2.7.4