Docs 菜单

MongoDB\add_logger()

1.17 版本中的新增功能

MongoDB\add_logger()

Registers a PSR logger to receive log messages from the extension.

function add_logger(Psr\Log\LoggerInterface $logger): void
$logger : Psr\Log\LoggerInterface

A logger to register.

If the logger is already registered, the method will have no effect.

This function allows the application to register one or more Psr\Log\LoggerInterface objects to receive log messages from libmongoc and the extension. Each registered logger will receive messages for 所有 clients.

Messages originating from the extension will have their log level translated to an equivalent PSR log level. For performance reasons, trace-level messages from the extension are not forwarded to PSR loggers. The extension's mongodb.debug INI configuration must be used to collect trace-level logs.

Log messages also include a domain string that identifies the driver component that emitted the log message. This value is provided to the PSR logger via the {{domain}} key of the context array.

MongoDB\Exception\InvalidArgumentException表示与参数或选项解析相关的错误。