Skip to content

Commit bcf3d9b

Browse files
committed
Use the pretty MONGOC macros
1 parent d5223ec commit bcf3d9b

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

php_phongo.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t
9494
return php_phongo_connectionexception_ce;
9595
}
9696

97-
mongoc_log(MONGOC_LOG_LEVEL_ERROR, MONGOC_LOG_DOMAIN, "Resolving unknown exception domain!!!");
97+
MONGOC_ERROR("Resolving unknown exception domain!!!");
9898
return spl_ce_RuntimeException;
9999
}
100100
zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code)
@@ -743,7 +743,7 @@ void phongo_stream_destroy(mongoc_stream_t *stream_wrap) /* {{{ */
743743
{
744744
php_phongo_stream_socket *base_stream = (php_phongo_stream_socket *)stream_wrap;
745745

746-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Not destroying RSRC#%d", base_stream->stream->rsrc_id);
746+
MONGOC_DEBUG("Not destroying RSRC#%d", base_stream->stream->rsrc_id);
747747
/*
748748
* DON'T DO ANYTHING TO THE INTERNAL base_stream->stream
749749
* The stream should not be closed during normal dtor -- as we want it to
@@ -760,7 +760,7 @@ void phongo_stream_failed(mongoc_stream_t *stream_wrap) /* {{{ */
760760
if (base_stream->stream) {
761761
TSRMLS_FETCH_FROM_CTX(base_stream->tsrm_ls);
762762

763-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Destroying RSRC#%d", base_stream->stream->rsrc_id);
763+
MONGOC_DEBUG("Destroying RSRC#%d", base_stream->stream->rsrc_id);
764764
php_stream_free(base_stream->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
765765
base_stream->stream = NULL;
766766
}
@@ -772,7 +772,7 @@ int phongo_stream_close(mongoc_stream_t *stream_wrap) /* {{{ */
772772
{
773773
php_phongo_stream_socket *base_stream = (php_phongo_stream_socket *)stream_wrap;
774774

775-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Closing RSRC#%d", base_stream->stream->rsrc_id);
775+
MONGOC_DEBUG("Closing RSRC#%d", base_stream->stream->rsrc_id);
776776
phongo_stream_destroy(stream_wrap);
777777
return 0;
778778
} /* }}} */
@@ -788,7 +788,7 @@ void php_phongo_set_timeout(php_phongo_stream_socket *base_stream, int32_t timeo
788788
}
789789

790790
php_stream_set_option(base_stream->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &rtimeout);
791-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Setting timeout to: %d", timeout_msec);
791+
MONGOC_DEBUG("Setting timeout to: %d", timeout_msec);
792792
} /* }}} */
793793

794794
ssize_t phongo_stream_writev(mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, int32_t timeout_msec) /* {{{ */
@@ -818,7 +818,7 @@ ssize_t phongo_stream_readv(mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t
818818

819819
do {
820820
read = php_stream_read(base_stream->stream, iov[cur].iov_base, iov[cur].iov_len);
821-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Reading got: %zd wanted: %zd", read, min_bytes);
821+
MONGOC_DEBUG("Reading got: %zd wanted: %zd", read, min_bytes);
822822

823823
if (read <= 0) {
824824
if (ret >= (ssize_t)min_bytes) {
@@ -1042,7 +1042,7 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
10421042

10431043
spprintf(&uniqid, 0, "%s:%d[%s]", host->host, host->port, mongoc_uri_get_string(uri));
10441044

1045-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Connecting to '%s'", uniqid);
1045+
MONGOC_DEBUG("Connecting to '%s'", uniqid);
10461046
stream = php_stream_xport_create(dsn, dsn_len, 0, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT | STREAM_XPORT_CONNECT_ASYNC, uniqid, timeoutp, (php_stream_context *)user_data, &errmsg, &errcode);
10471047

10481048
if (!stream) {
@@ -1056,15 +1056,15 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
10561056
}
10571057
php_stream_auto_cleanup(stream);
10581058

1059-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Created: RSRC#%d as '%s'", stream->rsrc_id, uniqid);
1059+
MONGOC_DEBUG("Created: RSRC#%d as '%s'", stream->rsrc_id, uniqid);
10601060
efree(uniqid);
10611061

10621062
if (mongoc_uri_get_ssl(uri)) {
10631063
zend_error_handling error_handling;
10641064

10651065
zend_replace_error_handling(EH_THROW, php_phongo_sslconnectionexception_ce, &error_handling TSRMLS_CC);
10661066

1067-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Enabling SSL");
1067+
MONGOC_DEBUG("Enabling SSL");
10681068

10691069
/* Capture the server certificate so we can do further verification */
10701070
if (stream->context) {
@@ -1126,7 +1126,7 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
11261126
int flag = 1;
11271127

11281128
if (phongo_stream_setsockopt((mongoc_stream_t *)base_stream, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int))) {
1129-
mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, "setsockopt TCP_NODELAY failed");
1129+
MONGOC_WARNING("setsockopt TCP_NODELAY failed");
11301130
}
11311131
}
11321132

@@ -1308,11 +1308,14 @@ mongoc_client_t *php_phongo_make_mongo_client(const char *uri, zval *driverOptio
13081308
php_stream_context *ctx;
13091309
const char *mech;
13101310
const mongoc_uri_t *muri;
1311-
mongoc_client_t *client = mongoc_client_new(uri);
1311+
mongoc_client_t *client = mongoc_client_new(uri);
1312+
1313+
1314+
ENTRY;
13121315

13131316

13141317
if (!client) {
1315-
return false;
1318+
RETURN(false);
13161319
}
13171320

13181321
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "context", strlen("context") + 1, (void**)&tmp) == SUCCESS) {
@@ -1392,7 +1395,7 @@ mongoc_client_t *php_phongo_make_mongo_client(const char *uri, zval *driverOptio
13921395

13931396
mongoc_client_set_stream_initiator(client, phongo_stream_initiator, ctx);
13941397

1395-
return client;
1398+
RETURN(client);
13961399
} /* }}} */
13971400

13981401
void php_phongo_new_utcdatetime_from_epoch(zval *object, int64_t msec_since_epoch TSRMLS_DC) /* {{{ */

0 commit comments

Comments
 (0)