Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F629140
logging-addSubscriber-003.phpt
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
logging-addSubscriber-003.phpt
View Options
--TEST--
MongoDB\Driver\Monitoring\addSubscriber(): Adding the same logger multiple times is a NOP
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
use MongoDB\Driver\Monitoring\LogSubscriber;
use function MongoDB\Driver\Monitoring\addSubscriber;
use function MongoDB\Driver\Monitoring\mongoc_log;
class MyLogger implements LogSubscriber
{
public function log(int $level, string $domain, string $message): void
{
printf("%d: %s: %s\n", $level, $domain, $message);
}
}
$logger = new MyLogger;
addSubscriber($logger);
mongoc_log(LogSubscriber::LEVEL_ERROR, 'domain', 'error');
mongoc_log(LogSubscriber::LEVEL_CRITICAL, 'domain', 'critical');
mongoc_log(LogSubscriber::LEVEL_WARNING, 'domain', 'warning');
addSubscriber($logger);
mongoc_log(LogSubscriber::LEVEL_MESSAGE, 'domain', 'message');
mongoc_log(LogSubscriber::LEVEL_INFO, 'domain', 'info');
mongoc_log(LogSubscriber::LEVEL_DEBUG, 'domain', 'debug');
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
0: domain: error
1: domain: critical
2: domain: warning
3: domain: message
4: domain: info
5: domain: debug
===DONE===
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 6:04 AM (12 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
145121
Default Alt Text
logging-addSubscriber-003.phpt (1 KB)
Attached To
Mode
R114 php-mongodb
Attached
Detach File
Event Timeline