Permalink
Browse files

Merged pull request mongodb#696

  • Loading branch information...
derickr committed Dec 12, 2017
2 parents 0f31fc4 + 03da646 commit 8dddf2437c3a9baf46f987e65d0117ba89e6736e
View
@@ -213,16 +213,24 @@ void phongo_throw_exception_from_bson_error_t(bson_error_t *error TSRMLS_DC)
{
zend_throw_exception(phongo_exception_from_mongoc_domain(error->domain, error->code), error->message, error->code TSRMLS_CC);
}
static void php_phongo_log(mongoc_log_level_t log_level, const char *log_domain, const char *message, void *user_data)
{
phongo_char *dt;
struct timeval tv;
time_t t;
phongo_long tu;
phongo_char *dt;
PHONGO_TSRMLS_FETCH_FROM_CTX(user_data);
(void)user_data;
dt = php_format_date((char *) ZEND_STRL("Y-m-d\\TH:i:sP"), time(NULL), 0 TSRMLS_CC);
gettimeofday(&tv, NULL);
t = tv.tv_sec;
tu = tv.tv_usec;
dt = php_format_date((char *) ZEND_STRL("Y-m-d\\TH:i:s"), t, 0 TSRMLS_CC);
fprintf(MONGODB_G(debug_fd), "[%s] %10s: %-8s> %s\n", ZSTR_VAL(dt), log_domain, mongoc_log_level_str(log_level), message);
fprintf(MONGODB_G(debug_fd), "[%s.%06lu+00:00] %10s: %-8s> %s\n", ZSTR_VAL(dt), tu, log_domain, mongoc_log_level_str(log_level), message);
fflush(MONGODB_G(debug_fd));
efree(dt);
}
@@ -1,7 +1,5 @@
--TEST--
MongoDB\Driver\Manager: Writing debug log files
--SKIPIF--
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
--FILE--
<?php
@@ -1,7 +1,5 @@
--TEST--
MongoDB\Driver\Manager: mongodb.debug=stderr
--SKIPIF--
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
MongoDB\Driver\Manager: mongodb.debug=stderr (connection string and version)
--INI--
mongodb.debug=stderr
--FILE--
@@ -0,0 +1,13 @@
--TEST--
MongoDB\Driver\Manager: mongodb.debug=stderr (date format)
--INI--
mongodb.debug=stderr
--FILE--
<?php
$manager = new MongoDB\Driver\Manager;
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
[%r(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}\+00:00)%r]%A
===DONE===%A

0 comments on commit 8dddf24

Please sign in to comment.