Skip to content

Commit

Permalink
Merge pull request #64 from piotras/ratatoskr
Browse files Browse the repository at this point in the history
Propagate GLib errors as PHP ones
  • Loading branch information
piotras committed Oct 12, 2011
2 parents 6ff2bd8 + a29647b commit 030cb05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ midgard.quota
Disable or enable quota check. Default is 'Off'.
You can change it between requests and also use in .htaccess files.

midgard.glib_loghandler
Propagate GLib and GLib-GObject domains errors as PHP ones. Default is 'Off'.
Enable or disable when module is loaded.

########################################################
############# HTTP SERVER NOTES ######################
Expand Down
10 changes: 8 additions & 2 deletions midgard.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ STD_PHP_INI_BOOLEAN("midgard.engine", "1", PHP_INI_ALL, OnUpdate
STD_PHP_INI_BOOLEAN("midgard.memory_debug", "0", PHP_INI_ALL, OnUpdateBool, midgard_memory_debug, zend_midgard2_globals, midgard2_globals)
STD_PHP_INI_BOOLEAN("midgard.superglobals_compat", "0", PHP_INI_SYSTEM, OnUpdateBool, superglobals_compat, zend_midgard2_globals, midgard2_globals)
STD_PHP_INI_BOOLEAN("midgard.valgrind_friendly", "0", PHP_INI_SYSTEM, OnUpdateBool, valgrind_friendly, zend_midgard2_globals, midgard2_globals)
STD_PHP_INI_BOOLEAN("midgard.glib_loghandler", "0", PHP_INI_SYSTEM, OnUpdateBool, glib_loghandler, zend_midgard2_globals, midgard2_globals)
PHP_INI_END()

static zend_bool php_midgard_engine_is_enabled(TSRMLS_D)
Expand Down Expand Up @@ -312,8 +313,8 @@ PHP_MINIT_FUNCTION(midgard2)
global_loghandler = g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, midgard_error_default_log,
NULL);

g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
g_log_set_fatal_mask("GLib-GObject", G_LOG_LEVEL_WARNING);
//g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
//g_log_set_fatal_mask("GLib-GObject", G_LOG_LEVEL_WARNING);

/* Get DateTime class pointer and set global */
zend_datetime_class_ptr = php_date_get_date_ce();
Expand Down Expand Up @@ -465,6 +466,11 @@ PHP_MINIT_FUNCTION(midgard2)

php_midgard_log_enabled = TRUE;

if (MGDG(glib_loghandler)) {
g_log_set_handler("GLib", G_LOG_LEVEL_MASK, php_midgard_log_errors, NULL);
g_log_set_handler("GLib-GObject", G_LOG_LEVEL_MASK, php_midgard_log_errors, NULL);
}

if (MGDG(midgard_memory_debug)) {
php_printf("MINIT done (pid = %d)\n", getpid());
}
Expand Down
1 change: 1 addition & 0 deletions php_midgard.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ZEND_BEGIN_MODULE_GLOBALS(midgard2)
zend_bool midgard_memory_debug;
zend_bool superglobals_compat;
zend_bool valgrind_friendly;
zend_bool glib_loghandler;
ZEND_END_MODULE_GLOBALS(midgard2)

ZEND_EXTERN_MODULE_GLOBALS(midgard2)
Expand Down

0 comments on commit 030cb05

Please sign in to comment.