Skip to content

Commit a5657d7

Browse files
authored
PHPLIB-1243: Document add/remove logger functions (#1191)
1 parent 53ccbc4 commit a5657d7

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
arg_name: param
2+
name: $logger
3+
type: Psr\\Log\\LoggerInterface
4+
description: |
5+
A logger to register.
6+
7+
If the logger is already registered, the method will have no effect.
8+
interface: phpmethod
9+
operation: ~
10+
optional: false
11+
...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
arg_name: param
2+
name: $logger
3+
type: Psr\\Log\\LoggerInterface
4+
description: |
5+
A logger to unregister.
6+
7+
If the logger is not registered, the method will have no effect.
8+
interface: phpmethod
9+
operation: ~
10+
optional: false
11+
...
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=====================
2+
MongoDB\\add_logger()
3+
=====================
4+
5+
.. versionadded:: 1.17
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\add_logger()
19+
20+
Registers a PSR logger to receive log messages from the driver.
21+
22+
.. code-block:: php
23+
24+
function add_logger(Psr\Log\LoggerInterface $logger): void
25+
26+
This method has the following parameters:
27+
28+
.. include:: /includes/apiargs/function-add_logger-param.rst
29+
30+
Behavior
31+
--------
32+
33+
This function allows the application to register one or more
34+
`Psr\\Log\\LoggerInterface <https://www.php-fig.org/psr/psr-3/#3-psrlogloggerinterface>`__
35+
objects to receive log messages from libmongoc and the driver. Each registered
36+
logger will receive messages for *all* clients.
37+
38+
Messages originating from the extension will have their log level translated to
39+
an equivalent `PSR log level <https://www.php-fig.org/psr/psr-3/#5-psrlogloglevel>`__.
40+
For performance reasons, trace-level messages from the extension are *not*
41+
forwarded to PSR loggers. The extension's
42+
:php:`mongodb.debug <manual/en/mongodb.configuration.php#ini.mongodb.debug>` INI
43+
configuration must be used to collect trace-level logs.
44+
45+
Log messages also include a domain string that identifies the driver component
46+
that emitted the log message. This value is provided to the PSR logger via the
47+
{{domain}} key of the context array.
48+
49+
Errors/Exceptions
50+
-----------------
51+
52+
.. include:: /includes/extracts/error-invalidargumentexception.rst
53+
54+
See Also
55+
--------
56+
57+
- :phpmethod:`MongoDB\\remove_logger()`
58+
- `PSR-3: Logger Interface <https://www.php-fig.org/psr/psr-3/>`__
59+
- `libmongoc: Logging <https://mongoc.org/libmongoc/current/logging.html>`__
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
========================
2+
MongoDB\\remove_logger()
3+
========================
4+
5+
.. versionadded:: 1.17
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\remove_logger()
19+
20+
Unregisters a PSR logger to no longer receive log messages from the driver.
21+
22+
.. code-block:: php
23+
24+
function remove_logger(Psr\Log\LoggerInterface $logger): void
25+
26+
This method has the following parameters:
27+
28+
.. include:: /includes/apiargs/function-remove_logger-param.rst
29+
30+
Errors/Exceptions
31+
-----------------
32+
33+
.. include:: /includes/extracts/error-invalidargumentexception.rst
34+
35+
See Also
36+
--------
37+
38+
- :phpmethod:`MongoDB\\add_logger()`
39+
- `PSR-3: Logger Interface <https://www.php-fig.org/psr/psr-3/>`__
40+
- `libmongoc: Logging <https://mongoc.org/libmongoc/current/logging.html>`__

docs/reference/functions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ Functions
1313
.. toctree::
1414
:titlesonly:
1515

16+
/reference/function/add_logger
17+
/reference/function/remove_logger
1618
/reference/function/with_transaction

0 commit comments

Comments
 (0)