Skip to content

Commit

Permalink
Adding zookeeper.log_level as a php.ini setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jørgen Trosby committed Jun 14, 2010
1 parent 5a8c1f6 commit eb548a5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
34 changes: 31 additions & 3 deletions php_zookeeper.c
Expand Up @@ -1133,8 +1133,39 @@ int php_zookeeper_get_connection_le()
}
#endif

static PHP_INI_MH(OnUpdateLogLevel) /* {{{ */
{
if(!strcasecmp(new_value, "error"))
{
ZK_G(log_level) = ZOO_LOG_LEVEL_ERROR;
}
else if(!strcasecmp(new_value, "warn"))
{
ZK_G(log_level) = ZOO_LOG_LEVEL_WARN;
}
else if(!strcasecmp(new_value, "info"))
{
ZK_G(log_level) = ZOO_LOG_LEVEL_INFO;
}
else if(!strcasecmp(new_value, "debug"))
{
ZK_G(log_level) = ZOO_LOG_LEVEL_DEBUG;
}
else
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "zookeeper.log_level must be in set {error, warn, info, debug} ('%s' given)", new_value);
return FAILURE;
}

zoo_set_debug_level((ZooLogLevel) ZK_G(log_level));

return SUCCESS;
}
/* }}} */

PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("zookeeper.recv_timeout", "10000", PHP_INI_ALL, OnUpdateLongGEZero, recv_timeout, zend_php_zookeeper_globals, php_zookeeper_globals)
STD_PHP_INI_ENTRY("zookeeper.log_level", "info", PHP_INI_ALL, OnUpdateLogLevel, log_level, zend_php_zookeeper_globals, php_zookeeper_globals)
#ifdef HAVE_ZOOKEEPER_SESSION
STD_PHP_INI_ENTRY("zookeeper.session_lock", "1", PHP_INI_SYSTEM, OnUpdateBool, session_lock, zend_php_zookeeper_globals, php_zookeeper_globals)
STD_PHP_INI_ENTRY("zookeeper.sess_lock_wait", "150000", PHP_INI_ALL, OnUpdateLongGEZero, sess_lock_wait, zend_php_zookeeper_globals, php_zookeeper_globals)
Expand All @@ -1152,9 +1183,6 @@ PHP_MINIT_FUNCTION(zookeeper)
zookeeper_ce = zend_register_internal_class(&ce TSRMLS_CC);
zookeeper_ce->create_object = php_zk_new;

/* set debug level to warning by default */
zoo_set_debug_level(ZOO_LOG_LEVEL_WARN);

php_zk_register_constants(INIT_FUNC_ARGS_PASSTHRU);

#ifdef ZTS
Expand Down
1 change: 1 addition & 0 deletions php_zookeeper.h
Expand Up @@ -38,6 +38,7 @@ extern zend_module_entry zookeeper_module_entry;
ZEND_BEGIN_MODULE_GLOBALS(php_zookeeper)
HashTable callbacks;
long recv_timeout;
long log_level;
zend_bool session_lock;
long sess_lock_wait;
ZEND_END_MODULE_GLOBALS(php_zookeeper)
Expand Down

0 comments on commit eb548a5

Please sign in to comment.