File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 3
3
$ uri = 'mongodb://localhost:27017 ' ;
4
4
$ uriOptions = ['serverSelectionTimeoutMS ' => 10000 ];
5
5
6
- $ client = new MongoDB \Client ($ uri , $ uriOptions );
6
+ $ client = new MongoDB \Client ($ uri , $ uriOptions );
Original file line number Diff line number Diff line change 3
3
require 'vendor/autoload.php ' ;
4
4
5
5
// start-monolog-logger
6
- use Monolog \Logger ;
7
6
use Monolog \Handler \StreamHandler ;
7
+ use Monolog \Logger ;
8
8
9
9
$ logger = new Logger ('mongodb-logger ' );
10
10
$ logger ->pushHandler (new StreamHandler (__DIR__ . '/mongodb.log ' , Logger::DEBUG ));
14
14
15
15
// start-custom-logger
16
16
use Psr \Log \AbstractLogger ;
17
- use Psr \Log \LoggerInterface ;
18
- use Psr \Log \LogLevel ;
19
- use MongoDB \PsrLogAdapter ;
20
17
21
18
class MyLogger extends AbstractLogger
22
19
{
23
20
public array $ logs = [];
24
21
25
- public function log ($ level , $ message , array $ context = []): void
22
+ public function log (string $ level , string | \ Stringable $ message , array $ context = []): void
26
23
{
27
24
$ this ->logs [] = [$ level , $ message , $ context ['domain ' ]];
28
25
}
Original file line number Diff line number Diff line change 5
5
// start-command-subscriber
6
6
class MyCommandSubscriber implements MongoDB \Driver \Monitoring \CommandSubscriber
7
7
{
8
- public function __construct (private $ stream ) {}
8
+ /** @param resource $stream */
9
+ public function __construct (private $ stream )
10
+ {}
9
11
10
12
public function commandStarted (MongoDB \Driver \Monitoring \CommandStartedEvent $ event ): void
11
13
{
You can’t perform that action at this time.
0 commit comments