Changeset 12158

Show
Ignore:
Timestamp:
09/12/07 12:37:43 (1 year ago)
Author:
piotras
Message:

Set global_loghandler when module is loaded, remove it when
connection is opened and set new loghandler associated with midgard_connection

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/apis/php5/midgard.c

    r11189 r12158  
    4444static MidgardConnection *inherited_cnc; 
    4545static void _make_midgard_global();   
     46guint global_loghandler; 
    4647/* End of true globals */ 
    4748 
     
    975976        zend_class_entry ce; 
    976977 
    977         /* FIXME, switch to php error log when connection is established  
    978          * or when connection pointer is available */ 
    979         g_log_set_handler("midgard-core", G_LOG_LEVEL_MASK, 
    980                         midgard_error_default_log, 
    981                         NULL); 
     978        global_loghandler =  
     979                g_log_set_handler("midgard-core", G_LOG_LEVEL_MASK, 
     980                                midgard_error_default_log, NULL); 
    982981                 
    983982        g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);  
     
    12251224MGD_FUNCTION(ret_type, config_init, (type_param)) 
    12261225{ 
    1227         gchar *fname
    1228         gint fname_lenght
     1226        gchar *conf
     1227        gint conf_length
    12291228        MidgardConnection *mgd; 
    12301229        RETVAL_FALSE; 
    12311230 
    1232         g_warning("This function is deprecated. Use midgard_connection class"); 
    1233  
    1234         return; 
     1231        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", 
     1232                                &conf, &conf_length) == FAILURE) 
     1233                return; 
     1234 
     1235        /* Check if connection is established */ 
     1236        if(mgd_handle() != NULL) { 
     1237                 
     1238                php_error(E_NOTICE,  
     1239                                "mgd_config_init is deprecated. Use midgard_connection class"); 
     1240                RETURN_TRUE; 
     1241        } 
     1242         
     1243        /* TODO , open connection here if really needed for some backward compatibility */       
    12351244} 
    12361245 
  • trunk/midgard/apis/php5/php_midgard.h

    r12153 r12158  
    1818Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919*/ 
     20 
     21#ifdef G_LOG_DOMAIN 
     22#undef G_LOG_DOMAIN 
     23#define G_LOG_DOMAIN "midgard-core" 
     24#endif 
     25 
     26guint global_loghandler; 
    2027 
    2128#ifndef PHP_MIDGARD_H 
  • trunk/midgard/apis/php5/php_midgard_connection.c

    r11307 r12158  
    1818#include "php_midgard_gobject.h" 
    1919 
     20guint global_loghandler; 
     21 
    2022static zend_class_entry *php_midgard_connection_class; 
    2123 
     
    177179{ 
    178180        RETVAL_FALSE; 
    179         CHECK_MGD; 
    180181        gchar *cnf_name; 
    181182        guint cnf_name_length; 
     
    193194        if(hash != NULL) 
    194195                g_hash_table_destroy(hash); 
     196 
     197        if(rv) { 
     198                 
     199                if(global_loghandler) 
     200                        g_log_remove_handler(G_LOG_DOMAIN, global_loghandler); 
     201 
     202                guint loghandler = 
     203                        g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, 
     204                                        php_midgard_log_errors, (gpointer)mgd); 
     205                midgard_connection_set_loghandler(mgd, loghandler); 
     206        } 
    195207 
    196208        RETURN_BOOL(rv);